Home > Language Reference > Program Flow Functions > Run


The Run function executes an already compiled script.


Used to run sub-scripts in a main script.


ret=Run (<script_name> [ <argument1> <argument2> ...])


The parameter is a string including first <script_name>, name of the compiled script to run, then a space, then optional <argument> separated by space.

If <script_name> contains spaces, you must surround the name by CHR$(34):
Run(chr$(34)+"C:\program files\my scripts\my_script"+chr$(34)+" param1")

Return value

ret, integer. The return value is 0 if the execution ended without errors. If an execution error occurs, you can use End function to set a return code which is passed to ret, return value of the Run.

If <script_name> is empty, an error occurs at execution time (ret=40). If the .ROB does not exist, no matter how #IgnoreErrors is set, an error message is displayed and the script is stopped.


System variables values are valid only inside one script; so if a parent script calls a child script through Run, the values of system variables set up in the parent are not passed to the child script.

If you want to run an external program (a .EXE, a .BAT), use Shell function.

See also

Parameters passed from one script to another


'Run my_script.rob with 2 parameters userid and pswd
Result = Run("My_script userid pswd")

'Create the full argument for the Run
b$=a$ + " " + usrid$ + " " + pswd$
Result = Run(b$)


'Return to the calling script the return code of the child script executed through a Run
    'Call a child script (already compiled)
    Ret=Run("script2"+" "+chr$(34)+file_to_find$+chr$(34))
    'Test return code
    If Ret=-1 then
        Mes$="Could not determine file count for "+file_to_find$
        Mes$="Number of file(s) "+File_to_find$+" : "+str$(Ret)

    Dim tab_name$(100)
    Dim short_name$(100)
    Dim att$(100)

   #IgnoreErrors=1   'Ignore Errors, script2 will not return any execution error but returns to parent script a return code.
    Res=Dir(command$(1), tab_name$(), short_name$(), att$(), "N")
    'Script2 return code is the return code of the Dir function
    'Script1 can test it as End function returns Res variable content to Script1