ScriptArgs
ScriptArgs is a global Maxbasic function which returns a collection of Variants corresponding to the arguments passed. In Maxbasic, ScriptArgs can be accessed directly as an Array (0 based), for example:
Print ScriptArgs[0]
ScriptArgs[0] will always contain the file name of the context, for example, if used inside a script, then ScriptArgs[0] will be the name of the script.
ScriptArgs.Count returns the number of parameters passed. ScriptArgs can be passed through the following functions:
Note: SetScriptArgs method passes the args to the Run method appended after any which are set directly on Run.
The above functions accept an infinite number of arguments after the required parameters, for example:
PlayScript("Script1.pfs", "Parameter1", 0, Date)
Inside script1.pfs the three ScriptArgs are accessed as follows:
Dim varString as String
varString = ""
Dim varNumber as Number
varNumber = 0
Dim varDate as Date
varDate = ##
If ScriptArgs.Count > 1 Then
varString = ScriptArgs[1]
varNumber = ScriptArgs[2]
varDate = ScriptArgs[3]
End If
Note: You should consider checking for the presence of SciptArgs before assigning them to variables, this is important as without this check scripts or reports relying on ScriptArgs will fail to run independently of the script that calls them.