Running a Script

IN THIS PAGE

Description

When you run a script you can choose one of three ways in which the script is run:

  • Standard

  • Local

  • Spawn

In most cases, the "Standard" choice will be satisfactory.

 Standard

When you choose this option, the Button Genie generates Xbasic code that uses the SCRIPT_PLAY() command. The script plays in the same session as its parent script (the script in which the SCRIPT_PLAY()command exists). However, the script that is played has its own variables. It does not see any of the variables that exist in its parent script. For example, say you have the following script:

DIM firstname as C
Firstname = "Peter"
Script_play("show_name")

Assume that show_name is a script that displays a message box with the contents of Firstname. The Xbasic in show_name is:

ui_msg_box("Firstname",firstname)

When the SCRIPT_PLAY()command in the parent script executes, an error will be generated because the script, show_name cannot see the firstname variable in its parent. Because the script runs in the same session as its parent, it can refer to any of the tables that are open in the primary session.

 Local

When you choose this option, the Button Genie generates Xbasic code that uses the SCRIPT_PLAY_LOCAL() command. The script plays in the same session as its parent script (the script in which the SCRIPT_PLAY_LOCAL() command exists). The script shares the same variables as its parent. In the above example, if the command:

Script_play("show_name")

is changed to:

Script_play_local("show_name")

then the show_name script will display the value in firstname, because it can see variables in its parent script. Furthermore, if a command in show_name changes the value in firstname, then when show_name ends, and control returns to the parent script, firstname will have been changed to the value set in the show_name script. Because the script runs in the same session as its parent, it can refer to any of the tables that are open in the primary session.

 Spawn

When you choose this option, the Button Genie generates Xbasic code that uses the SCRIPT_SPAWN() command. The script plays in its own session. The script can change the primary table in its session (using the TABLE.RESET() method), without impacting on the session in which the parent script is running. The script cannot see any of the variables in the parent script.