|
|
Recent News
|
Hotel Software DocumentationScripting Basics
IntroductionUsing 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, please see the chapter Script Designer Script ElementsAs an example we'll take the following script: Each 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 also can go to the specified line if it executes the Go To statement (line 6). Thus, you can use the following lines in any script: ActionsAn 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 they are represented by the following lines:
The action is specified by means of the Action Editor, that contains a description of parameters and convenient tools you can use to enter them. View list of actions VariablesVariables 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 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:
For more details about variables see the Using Variables section. If StatementsConditional 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 the designer nesting levels are marked by the left margin. In the designer conditional statements are highlighted blue. To add a conditional statement, click the button Add If/Else... Cycles (For Each ... Next)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:
Go To LabelUse the Go To 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 a Go To or Label, click the button Add Go To... In the designer Go To and Labels are highlighted
green with icons CommentsComments 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, press the button Add Comments. In the text comments are highlighted
green on a grey background.
See line 1 in the illustration.
See Also: |
Today"s Poll What software do use for your inn/b&b/hotel/etc? |
Home Page | Contacs | Terms and Conditions | Copyright (C) 2001-2010 Binary Brilliant Inc | |