Expressions |
An expression is:
Integer numbers are long integers, floating point numbers are doubles.
All methods and functions accept expressions as their parameters - the number expected is specified in the definition you will find in this manual. The only exception to this rule is represented by:
PUB(id)
require a variable name as its only parameter
and by the functions which require a function name as their parameter (e.g. SORTUDF).
It is possible to nest a function within a function, as in this example:
SET P = LEFT(RTRIM(LTRIM(S, " "), " "), INC(MUL(R, 2)))
Proteus determines the type of the variable according to the function being applied; strings and numbers are managed in the same way.
The numeric value of a string is determined by using this rule:
A few examples:
Method: |
Result |
CONSOLELN 1.23 |
1.23 |
CONSOLELN "1.23" |
1.23 |
CONSOLELN 123 |
123 |
CONSOLELN "123" |
123 |
CONSOLELN -123 |
-123 |
CONSOLELN "-123" |
-123 |
CONSOLELN 0XFF |
255 |
CONSOLELN "0XFF" |
0XFF |
CONSOLELN 070 |
56 |
CONSOLELN "070" |
070 |
CONSOLELN INC(LTRIM("070", "0")) |
71 |
CONSOLELN INC("070") |
57 |
CONSOLELN INC(070) |
57 |
Every string can include C-like
constants, to specify control characters.
The following escape sequences are supported:
\a \b \f \n \r \t \v \\ \? \' \"
and the octal, hexadecimal and decimal constants specified in this way:
By using one of the last three notations it is possible to specify every character between 0 and 255; in every case, if a constant out of the range is specified, the last digit will be discarded and considered as a character by itself.
e.g. \d512 will be interpreted as [51] [50] (the brackets are to be read as 'character corresponding to'; 50 is the ASCII code of the character '2')
At the same time, take care not to create a constant within the range by chaining a constant and a literal value.
Proteus can deal with strings including NULL characters (Ascii 0), but many functions stop interpreting the string at the first NULL; these are:
Many Windows-specific functions consider only NULL terminated strings, like their system counterparts, while all other functions operate correctly on strings including NULLs; these are, for example, the routines for extracting tokens and substrings, for joining strings, etc.
Start of page | Next topic | Previous topic | Contents | Index |