Variables |
A variable, in Proteus, can be a string, an integer number or a floating point number, without distinction. Every variable can change its type during execution and is automatically created the first time it appears in the source code.
A variable name is a sequence of characters (case unsensitive) of any length; spaces, tabs, double quotes and the symbols '=', '&', '|', '^', '*', '\', '/' are not allowed in the name, which cannot start with a digit (0-9), with a sign (+/-) or with characters '@' and '!'.
Variables cannot be used before having being assigned a value: if this happens, Proteus stops execution and warns the user, specifying the variable that triggered the exception.
Examples | ||
|
||
|
There are a few predefined variables:
L | current line (string) |
N | number of lines read |
S | size of input file (bytes) |
F | name of input file |
EOF | boolean flag: end of file? |
BOF | boolean flag: start of file? |
ARGC | number of parameters on the command line (minimum 4) |
EOL | line terminator, used by PRINTLN, FWRITELN, FINSERT; predefined value depends on the version being used: CR+LF for Dos/Windows, LF for Unix |
CEOL | line terminator, used by CONSOLELN and DEBUG; predefined value depends on the version being used: CR+LF for Dos/Windows, LF for Unix |
EEOL | line terminator, used by ERRORLN; predefined value depends on the version being used: CR+LF for Dos/Windows, LF for Unix |
OS | determined operating system: 0 = Unix 1 = Ms-Dos 2 = Windows 3 = Win32 ISAPI 4 = Win32 Service |
VERSION | interpreter version |
R_LENGTH | maximum length of the string found by the last call to REXMATCH/ REXIMATCH |
R_START | start of the string found by the last call to REXMATCH/ REXIMATCH |
MONTHS | string of 12 words, separated by spaces or commas, used as values returned by CMONTH (January -> December) |
DAYS | string of 7 words, separated by spaces or commas, used as values returned by CDOW (Sunday -> Saturday) |
EPOCH | reference value used to determine century in dates where year is specified by using only two digits; default value is 1970 |
DATE_TYPE | date format; determine how strings are interpreted by the functions on dates; possible
values:
if DATE_TYPE is different from 0-2, it is assumed 1 (european format) |
TIME_TYPE | time format (for DIRLAST, TIME); possible values:
In both cases, the time is 9 characters long; in 24 hour mode, the last character is space; in 12 hour mode, it is 'a' or 'p'. |
PROG_DATA | this variable is predefined only if the directive !endprog appears inside the program; its value becomes the offset in the script file of the first line following the directive |
FILE_MASK | this variable is predefined only under Unix; it sets the access
rights used for the creation of new files by the following functions:
As usual under Unix, these rights are masked by complementing the umask of the process (which can be modified through UMASK). The value assigned to this variabile must be a string of three octal numbers, from "000" to "777", representing the access rights to the file for the owner, the group and the others, respectively; each digit is the sum of the following values:
Initially, FILE_MASK is "000". |
PID | this variabile is predefined only under Unix; at the beginning of the execution its value is set to the value of the process id. |
R_LENGTH and R_START are set to 0 at the beginning and change their values after each call to REXMATCH/ REXIMATCH.
EOL, CEOL, MONTHS, DAYS, EPOCH, DATE_TYPE, TIME_TYPE and FILE_MASK should be updated during execution, if necessary; the other predefined variables can also be changed, even though this is not reccommended, because the program becomes difficult to understand.
Use PSET and PUB to access these variables from user defined functions (UDFs), or use the prefix '_' before the variable name: PUB(VARIABLE) is the same as _VARIABLE.
Start of page | Next topic | Previous topic | Contents | Index |