Exec – Visara Master Console Center Scripting Guide User Manual
Page 101
Chapter 5 Script Commands
Scripting Guide
101
EXEC
Syntax:
EXEC( $ScriptName[, Parm1, ...]) ==> ReturnValue
Description:
Executes a script whose name is stored in a string expression.
Action:
The script name stored in the ScriptName parameter is executed,
passing any of the values in the optionally specified parameters to the
called script. The calling script waits for the completion of the called
script and receives its return value.
Parameters:
$ScriptName. String expression. The name of the script to execute.
Parm1. Numeric or string expression. Optional. Zero or more
parameters to pass to the called script. Refer to the PARMS()
command for more information.
Returns:
Numeric or string value. The return value from the executed script.
Notes:
1. Execution of the parent script pauses until the child script has
finished execution.
2. Script names are case sensitive, so that calling “MYSCRIPT” is not
the same as a script called “Myscript”. We recommend using all
lower case characters for script names, so that the name of the
script is the same as the name of the physical script file on disk. In
that case, a call to “myscript” actually calls a script file on disk
named myscript.scx).
3. Functionally, EXEC is the same as directly calling the script as
demonstrated in the following examples.
//1—directly calling a script called “script1”
%ReturnValue := script1( $Parm1, %Parm2)
//2—using EXEC with the script name in a string expression
%ReturnValue := EXEC( “script1”, $Parm1, %Parm2)
//3—using EXEC with the script name in a variable
$ScriptName := “script1”
%ReturnValue := EXEC( $ScriptName, $Parm1, %Parm2)
All of the examples above have the same result:
1. script1 is run
2. $Parm1 and %Parm2 are passed as parameters to script1
3.
%ReturnValue is set to the return value from script1
Examples 1 and 2 above are the same and EXEC provides no added
benefit.
Example 3 demonstrates when to use the EXEC command versus
directly calling the script. EXEC has the added benefit of changing the
script called at runtime, because the script to call is specified in a
variable (and variables can be changed at runtime). The following
simple example illustrates this further:
IF %Status == 1