Home > FAQ > Useful Basic Tasks when writing a script > How do I find the window which has the focus?

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 Run function. 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 (the script name is the first parameter). 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 filename including its path, 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\\"

Command$(n) function 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 example:

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. End(x) function, in the child script, is used to return this return code. The calling script retrieves this return code by testing the result of Run function. For example:
Child script :

Calling script :
Res=Run("child.rob "+param1$+" "+param2$)
'Number 5 is displayed in the dialog box