User Tools

Site Tools


global_variables

Global Variables

Global variables are accessible from every Script. It is possible e.g. to assign a global variable a value in task A, and check this value in task B. Global variables are from type string only. Because every Script has access to global variables, it is not declared in a Script. To declare a global variable, select Cues → Add Global Variable… in the main menu or use the context menu of the Global Variables list.

Enter the name of the variable in the dialog box:

The new variable appears in the Global Variables list. At this point, the content of the new variable is an empty string “”.

To access the global variables, the commands GetGlobalVar and SetGlobalVar are used (available via main menu Insert → GetGlobalVar, Insert → SetGlobalVar or the Script Editor's context menu).

To assign a value to a global var, use the function SetGlobalVar. As shown in the picture above, it is available via Script Editor's context menu. In the following dialog (see below) select a variable from the list and enter a value for that variable:

–> –>

If this task is launched, the variable gblA gets the string “5” as content. To check this, mark the checkbox Show Var Content.

To read a global variable use GetGlobalVar. Instructions like “gblA” = “6” are invalid, because “gblA” is a string and not a variable. gblA = “6” is also invalid, because gblA is not declared in the Script and only (locally) declared variables are known. The solution is to declare a local variable of type string and assign the content of the global variable to that local one.

Dim gbl_A as string

Via main menu Insert → GetGlobalVar, or the Script Editor's context menu a dialogue box with all available global variables pops up. If a variable is selected a new dialogue box asks for the local variable, that gets the content of the global one.

The result looks like this:

now, the content of the global variable is available in the Script and we can work with it.

Dim i As Integer    'Local Integer variable
Dim gbl_A As String 'Local variable For the content of a Global variable

gbl_A = GetGlobalVar("gblA") 'Read Global variable
i = Val(gbl_A)   'convert To Integer

If i > 5 Then    'If > 5 Then reset Global variable To "0"
   SetGlobalVar("gblA","0")
Else   'If Not increment
   i = i + 1
   SetGlobalVar("gblA",Str(i)) 'And Write back As String
End
global_variables.txt · Last modified: 2013/08/12 21:21 by admin