Parameters passed from one script to another

 

Parameters passed from a calling script to a called script (parent script to child script)

Parameters can be passed to a called script using statement Run. Those parameters can be only string and a space must separate each of them. So a space must be included at the end of the script name (first parameter).

So syntax is :

Run("my_script[.rob] "+param1$+" "+param2$+" "+param3$)

Parameters paramn$ can be constant or variables. Maximum number of parameters is 16.

If a parameter is a full filename and if its path includes spaces, you must surround this parameter with quotes (CHR$(34)). So syntax is:

filename$="C:\program files\wintask\logs\file.log"

run("my_script.rob "+chr$(34)+filename$+chr$(34)+" "+param2$+" "+param3$)

If the parameter ends by a \, you must double the \, so for instance:
filename$="C:\program files\wintask\logs\file.log\\"

 

Statement Command$(n) can be used to retrieve the nth parameter in the called script. Note that command$(0) always returns the full name of the current script. Syntax is for instance:

file_to_use$=command$(1)

parameter2$=command$(2)

 

Parameters passed from a called script to a calling script (child script to a parent script)

A child script can only return a return code (integer) to the parent script. Statement end(x), in the child script, is used to return this return code. The calling script retrieves this return code by testing the result of Run statement. For instance:

Child script :

Return_code=5

End(return_code)

Calling script :

Res=Run("child.rob "+param1$+" "+param2$)

msgbox(str$(res))

Number 5 is displayed in the dialog box.