Error when running functions in PrimalScript

Use this forum to ask questions after your subscription maintenance expires or before you buy. Need information on licensing or pricing? Questions about a trial version? This is the right place for you. No scripting questions, please.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
This topic is 14 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
mbrouwer
Posts: 4
Last visit: Thu Mar 07, 2013 2:07 am

Error when running functions in PrimalScript

Post by mbrouwer »

Hi,

I am evaluating script editors at the moment and one thing I ran into with PrimalScript is this, the problem is I dont know if its my inexperience with PowerShell or a "feature" or PrimalScript.

I have a script and it needs the ScriptDirectory compareble to the @SCRIPTDIR in KiX. I found a function and it works as long as I run it from PowerShell itself, when it runs from PrimalScript it gives me an error.

The code:

Code: Select all

function Get-ScriptDirectory
{
 $Invocation = (Get-Variable MyInvocation -Scope 1).ValueSplit-Path $Invocation.MyCommand.Path
}
       
function multiplynumbers
{
 $args[0] * $args[1]
}
       
multiplynumbers 446 282
       
Get-ScriptDirectory

The Error:

Code: Select all

125772
	
ERROR: Split-Path : Cannot bind argument to parameter 'Path' because it is null.
ERROR: At line:4 char:44
ERROR: + psdbg-Outvar;Write-Host "@@#@@4";Split-Path <<<<  $Invocation.MyCommand.PathERROR:     + CategoryInfo          : InvalidData: (:) [Split-Path], ParameterBindingValidationException
ERROR:     + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SplitPathCommand
ERROR:
The output when ran from PowerShell:

Code: Select all

125772

C:UsersMarco Brouwer.MARCOSOFTDocumentsSAPIENScripts
User avatar
Alexander Riedel
Posts: 8488
Last visit: Tue Apr 16, 2024 8:42 am
Answers: 20
Been upvoted: 37 times

Error when running functions in PrimalScript

Post by Alexander Riedel »

$MyInvocation is technically a PowerShell Host feature, not a PowerShell feature. So it gets set by PowerShell.exe rather than the engine. As such it is a bit undocumented from the technical side.
We are aware of the problem and working on adding it to the PrimalScript host that runs scripts directly.

Alex
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 14 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.