The variables section is used to define values that you will use somewhere in the program. Typically you use variables to temporarily store information that you will need again later.
Unlike parameters, variables are not automatically given a value when you start the program. Therefore, if you define variables, you will have to remember to assign an initial value to them. You can either do this when defining them, or in the execution section of your program. If you forget to assign a value to a variable and later try to use it in a calculation, the result of the calculation will be invalid.
There is a special variable Result, which holds the return value for each program. This variable is created automatically in every program, and you do not have to define it in the variables section. The type of the Result variable (Numeric, Boolean or Text) is defined by the return type of the program.
This section is optional. If used, it has to be positioned at the end of the declaration section
Variables
VariableType
VariableName1;
VariableType
VariableName2(InitialValue);
VariableType VaraibleName3 =
InitialValue;
...
Variables |
Reserved word. You can also use Variable or Var instead. |
VariableType |
Possible variable types are:
Numeric Variable value is a number Text Variable value is text Boolean Variable value is the logical value True or False
You can also define custom types by using enumerations: See Enumerations. |
VariableName |
Choose a name for your variable (see Naming Conventions) |
InitialValue |
Set an initial value for the variable. There are two ways to initialize a variable in the declaration section – choose the one which you like best. This is an optional part of the variable declaration – you can also assign a value to the variable later in the execution section of your program (see Value Assignment for details). |
Define two variables that will hold the results of a calculation. You can later reuse these results in the same program.
Variables
Numeric diffHigh;
Numeric diffLow;
Define two variables and initialize them in the declaration section (note that both ways shown below are equally valid):
Variables
Numeric Counter1(0);
Numeric Counter2 = 0;