Brilliant Database Software - Home
Database software - Online Help System

Online Help System

Back to Brilliant Database Web-Site | Write to Support | Help Index



About Variables

table border="0" width="100%" cellspacing="0" cellpadding="4" bgcolor="#00000077">
About Variables

Introduction

This section outlines the guidelines for using variables in scripts.

Variables are used to store information that can further be used.

The values of variables can be set in scripts and user functions.

You can use variables almost everywhere: in math formulas, reports, queries, text formulas, custom export templates, etc.

In formulas the variable is usually shown in brackets and the $ character is added before the variable name, for example: [$a], [$order_date], [$text]. You can use all characters except [, ], $ and ^ in the variable name.

Variables Scopes

Starting from version 5.0, the program uses variable scopes. The variable scope defines the area where you can use the value of the variable.

All variables can be divided into local, global, static, predifined and syatem:

  • Local variables can be used only in scripts where they were created. For example, we placed a button on the form, and when we click this button, the [$title] variable is created in the script with a Dear Mr/Ms. If we add the output of this variable to the Report Style Template and click "File > Print...", we'll get an error message saying that the variable wasn't found. However, if we add a print command to the script where the variable was initialized, its value will be printed out in the report.
  • If the variable is declared as Global, it can be used in any part of the program. For example, if the [$title] variable was global in our example, we wouldn't get an error trying to print the text without adding the corresponding command to the script where the variable was declared. However, when we close the database, the variable value will be erased.
  • In contrast to global and local variables, the values of Static variables are stored in the database file and arent erased when we close the database. In networked mode it value is same to all users, so if one user set the variable [$x] value to "Hello World" and other users read this veriable they all will see the "Hello World" value.
  • Predefined. A predefined variable is a local variable, but unlike local variables it's defined before the script is executed. For example, the arguments of User Functions or variables given to the script after parsing are predefined variables.
  • System Variables are global variables that contain system values like the current time, name of the database user, etc. Their values cannot be changed.

All variables are shown in the variable tree. To make a local variable global (or static), right-click it and select the "Make Global" (or "Make Static") menu item:

Creating/Modifying Variables

To add a new variable to the script (or modify the existing value), click Add Variable in Script Editor:

Enter the name of the variable in the dialog box. Select the check box on the right to make the variable global:

After that, select data the variable should be based on. Depending on the data type, the variable creation dialog box can look differently.

By type, all variables can be divided into:

  • Text/Math/Date - regular variables that store text, numbers, dates, etc.
  • RecordSet - variables that store a record list for the further use or modification.



All topics in the "Variables" section: