Using script you can create a small program that will be executed in response to certain actions (pressing a button, changing field value, etc.).
This chapter describes the basics of scripting and script creation.
To learn more abut the actual script editor, see the Script Designer chapter.
As an example we'll take the following script:
Every script has one or several instruction lines (in our example it has 12 lines). The program executes the commands downwards (starting from the first line to the last one). The program can skip lines if the condition of the If statement (lines 4, 10) is not fulfilled. It can also go to the specified line if it executes the Go To statement (line 6).
Thus, you can use the following lines in any script:
An action defines one action, such as creating a new record or changing a field value. To add an action to the script, use the Add Action button. Actions can contain different parameters specified in brackets after the name of the action. Beside standard actions, you can also execute User Functions - a script you create beforehand. Learn more about User Functions...
Some actions can record their result to a selected variable. For example, the Import From a Database action returns the number of imported records.
In the illustration above actions are represented by the following lines:
Variables are used to store information. They have the following structure: [$VarName] For example, in this script the program:
Some actions can also record their result to the specified variables. For example, the Add Record action records 1 to the variable if the record was added and 0 (null) if the record wasn't added:
To learn more about variables, see the Using Variables section.
Conditional statements are used for carrying out actions only when some condition is true. For example, in the illustration above there are two conditional statements: one checks the variable quantity (line 4), the other one asks for the user's confirmation (line 10) and carries out action (line 11) only if the reply is affirmative. The following statements are available in the current version:
Note. Conditional statements can have several nesting levels. Statements Else, Else If and End If are used only together with the If statement on the same nesting level. In Script Designer nesting levels are marked by the left margin.
In Script Designer conditional statements are highlighted blue.
To add a conditional statement, click the Add If/Else... button.
Cycles (loops) allow performing the same actions (cycle body) over different objects or under different conditions. For example, you can calculate the total of numbers 1 through 100, perform operations over several records stored in the recordset variable at once or print individual lines from a text.
For example, the following script will increase the value of Field A by one for all records received from the All Records query:
Use the Go To () statement to execute a specific part of the script marked with the label.
In our example, if the condition in line 4 is not satisfied, the program will go to the specified begin line (line 2) according to the Go To statement (line 6).
To add Go To or Label, click the Add Go To... button.
In Script Designer Go To and Labels are highlighted green with icons , .
Comments do not affect script operation in any way. Their purpose is to provide the script with additional information, such as a brief description of the script operation or the last modification date.
To add a comment line, click the Add Comments button.
In the text comments are highlighted
green on the grey background.
See line 1 in the illustration.
Copyright (C) 2001-2010 Binary Brilliant Inc. All Rights Reserved.