next up previous contents index
Next: Initializing variables from external Up: Variables and Expressions Previous: GILDAS Headers   Contents   Index

Character Variables and Implicit Formatting

In contrast with the Symbols, which are substituted in the command line before the parsing, variables and expressions are evaluated after the command line analysis. In general, a real (resp. integer and logical) argument is considered as a mathematical (logical) expression and evaluated when read by the program calling SIC. The command line stored in the stack and logfile contains the mathematic expression, not the current value.

The behaviour for Character variables is slightly different, in the sense that only items included between single quotes are considered as possible character variables, if they have not yet been expanded as known symbols of course. Using character variables in logical expressions is an exception to this rule because translation should be avoided in this case, see next chapter. Contrary to Symbols, Character variables translation does not occur in strings.

Not only Character variables but also any mathematical and logical expression may be included between quotes. Mathematical expressions are evaluated and formatted using the shortest possible format. Logical expressions are evaluated as YES or NO. The formatted command string is substituted to the expression and quotes, and used in the string returned as character argument to a command. This feature is known as ``Implicit Formatting''. In this way, non-character variables and expressions can be used where a character argument is required. The reverse is not true however: Implicit Formatting should not be used if a non-character argument is expected.

Any variable can be typed using the EXAMINE command which will display the variable name followed by its current value. More than one variable may be displayed at the same time using the SAY command.

Concatenation of variables is easily obtained by mixing explicit strings (between double-quotes) and implicitely formatted variables. For example, is A is character variable of content "I am", the following command

   LET B "You know "'A'" happy"
attributes to B the content "You know I am happy".


next up previous contents index
Next: Initializing variables from external Up: Variables and Expressions Previous: GILDAS Headers   Contents   Index
Gildas manager 2014-07-01