Error when running functions in PrimalScript

Use this forum to ask questions 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.
User avatar
mbrouwer
Posts: 4
Joined: Tue Jun 09, 2009 10:57 pm

Error when running functions in PrimalScript

Post by mbrouwer » Tue Jun 09, 2009 11:35 pm

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: 6921
Joined: Tue May 29, 2007 4:43 pm

Error when running functions in PrimalScript

Post by Alexander Riedel » Wed Jun 10, 2009 12:41 am

$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.