LEO Operators and Functions ​
The following sections contain a list and descriptions of the various operators and functions that can be used in LEO expressions.
Logical Operators ​
Logical operators deliver 0 ("false") or 1 ("true"). Concerning the operators null values are interpreted as "false" and all other values are "true".
Operator | Description |
---|---|
a OR b | Logic or-connection. Delivers 1, if an operator is not 0 otherwise 0. |
a AND b | Logic and-connection. Delivers 1, if both operators are not 0, otherwise 0. |
NOT a | Logic negation. Delivers 1, if the operator is 0, otherwise 0. |
Comparison Operators ​
When evaluating a comparison operator, the value of the left operator must be of the same type as the value of the right operator. The result is 0 ("false") or 1 ("true").
Operator | Description |
---|---|
a < b | small operator. |
a <= b | small-same-operator. |
a = b | is-operator. |
a <> b | not-operator. |
a >= b | larger-than-operator. |
a > b | larger-Operator. |
Arithmetical Operators ​
For arithmetic operators the operands and the results are either of numeric type, of type measure or of type time.
Operator | Description |
---|---|
a + b | Addition. a and b both have to be of numeric type, of type measure or of type time. |
a - b | Subtraction. a and b both have to be of numeric type, of type measure or of type time. |
a * b | Multiplication. The following operand type combinations are evaluateable: number * number returns number, number * measure returns measure, measure * number returns measure, number * time returns time and time * number returns time. |
a / b | The following operand type combinations are evaluateable: number / number returns number, measure / number returns measure, time / number returns time, measure / measure returns real and time / time returns real. |
a MOD b | Modulo operator (remainder of division). Same as (a - INT (a / b) * b).a and b both must be of type integer. |
- a | Negation. Switches the leading sign of the value. The operand has to be of numeric type, of type measure or of type time. |
ROUND x | Commercial rounding. Rounds up if the decimal digits are >= 0.5, otherwise down. |
FLOOR x | Rounds down (to the next integer). |
CEIL x | Rounds up (to the next number). |
Arithmetical Functions ​
Function | Description |
---|---|
abs ( x ) | Absolute amount. |
max ( x , y ) | Maximum. |
min ( x , y ) | Minimum. |
pow ( x , y ) | Power (x high y). |
sqrt ( x ) | square root. |
exp ( x ) | Exponential function (e high x). |
log ( x ) | natural logarithms. |
log10 ( x ) | Logarithms on basis 10. |
sin ( x ) | Sine. |
cos ( x ) | Cosine. |
tan ( x ) | Tangent. |
asin ( x ) | Arcus sinus. |
acos ( x ) | Arcus cosinus. |
atan ( x ) | Arcus tangens. |
sinh ( x ) | Sine hyperbolicus. |
cosh ( x ) | Cosine hyperbolicus. |
tanh ( x ) | Tangent hyperbolicus. |
random ( ) | coincidence figure >= 0 und < 1. |
round ( x ) | rounding. The next integer will be delivered where as from including 0.5 as commas . |
floor ( x ) | off rounding. If x has decimal places the next smaller figure will be returned otherwise x. |
ceil ( a ) | up rounding. If x has decimal places the next larger figure will be returned otherwise x. |
String Operators ​
Operator | Description |
---|---|
s + t | one following one s and t. Both operators are from the type string the result is also a string. |
n * s | n-one following one s. An operator must be from the type figure and the other from the type string. You could also write s * n . The result is from the type string. |
s / t | Number of appearing t in s. Both operators have to be from the type string, the result has to be from the character figure. |
s SUB i | Subscription of the string. s must be from the type string, i from the type figure. The identification of a character starts with 0. The result is a string, which is the i-character of s. |
LEN s | Length of a string. The operator s is of the type string, and the result (the number of characters of s) is of type figure. |
String Functions ​
Hint
For tokcnt, token, tokcat, tocunion, tokiset, and tokdiff, separator is a single character separating the tokens (default: single white space ).
Hint
While the tokcnt, token, tokcat, tocunion, tokiset, and tokdiff functions are mainly used for processing tokenStr
values, they can be used for any text string.
Search ​
search ( source , pattern , start )
source and pattern are of type string, start from type figure. The result is of type figure. It will be searched in source after pattern, but the start has a specified position. The identification starts with the character 0. If the search was successful the position will be shown, if not it will return -1.
Backwards search ​
bsearch ( source , pattern , start )
source and pattern are of type string, start from type figure. The result is of type figure. It will be searched backwards in source after pattern,start is the specific position in which it will be started. The identification of a character starts with 0, -1 is the end of the text. If the search was successful the position will be shown, if not it will return -1.
Copy ​
copy ( source , from , count )
source of type string, from and count are of type figure. The result is of type figure. The part-text which will be delivered back by source, is the starting position starting at from and continuing for the length of count. For count the value -1 will be displayed, the part-text from source starting from from to the end of the string.
Replace ​
replace ( source , pattern , new )
source, pattern and new are of type string. The result is source, where the first appearance of pattern via new is set. If the pattern is not in the source, the unchanged value of the source is provided.
Replace all ​
replall ( source , pattern , new )
source, pattern and new are of type string. The result is of type string. The text displayed is created as a result of replacing (in the source) all patterns with news.
To lower case ​
lower ( source )
The string will be returned, but all capital letters in source will bhe replaced with the appropriate lower-case letters.
Hint
When changing the string into small or capital letters (lower or upper) only the letters from a to z, or A to Z will be considered. Special characters will not be converted.
To upper-case ​
upper ( source )
The string will be returned, but all small letters in source will be replaced with the appropriate capital letters.
Hint
When changing the string into small or capital letters (lower or upper) only the letters from a to z, or A to Z will be considered. Special characters will not be converted.
Mask string ​
mstr ( source )
The returned string will be passed as a parameter in inverted commas returned with required masks.
Escape characters for URI ​
encodeuri ( content [ , allowed ])
The returned string will have it's characters escaped using typical URI encoding (%xx
, "percent-encoding"). The optional allowed parameter specifies all characters that are allowed to appear normally (not encoded) in the result. If allowed is omitted then the same characters are allowed as in the encodeURI()
function from JavaScript.
Be careful where the input comes from. This function does not consider the string to have any specific structure. If parts of it have already been encoded (from encodeuri()
or tourlquerystring()
) then they will be encoded again!
Examples for some strings that can be used for allowed:
# Characters allowed by JS encodeURIComponent(). It should be safe to encode
# specific parts of a URL.
"!'()*-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~"
# Characters allowed by JS encodeURI(). It should be safe to use for encoding
# an entire URL.
"!#$&'()*+,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~"
# Based on several sources from the internet, including the URI specification.
"!\"$'()*,-./0123456789;ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~"
# All except non-ASCII characters, ASCII control characters (0x00 to 0x20 and
# 0x7F), # (0x23), % (0x25), & (0x26), + (0x2B), = (0x3D) and ? (0x3F)
"!\"$'()*,-./0123456789:;<>@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
# All except non-ASCII characters, ASCII control characters (0x00 to 0x20 and
# 0x7F), % (0x25), & (0x26) and = (0x3D)
"!\"#$'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
Regular expression ​
regex ( regExpr , source )
The comparison of source with the regular expression_regExpr_. It corresponds to the regular expression source, it gets the value 1 or 0.
Token count ​
tokcnt ( source , [ separator ])
Returns the number of tokens in source separaetd by separator.
Get token ​
token ( source , index , separator )
The token in source with the index index will be returned, but with the beginning of the token starting at 0. separator is a single character which separates the tokens.
Index of token ​
tokindex ( source , token [, separator ])
The result is the index of token in source (starting with 0). A result of -1 means that token is not a token in source. Example: tokindex("this@is@a@simple@test", "simple", "@") = 3
Token concatenation ​
tokcat ( source1 , source2 [, separator ])
From the strings source1 and source2 a new string is generated, which contains all the tokens from source1 and source2.
Token union ​
tokunion ( source1 , source2 [, separator ])
The set union of the second string. The result contains all tokens which appear in source1 and/or in source2.
Hint
Different to tokcat, values existing more than once are only given back once.
Token intersection ​
tokisect ( source1 , source2 [, separator ])
The intersection of the second string. The result contains all tokens, which appear both in source1 and in source2.
Token difference ​
tokdiff ( source1 , source2 [, separator ])
The difference between two strings. The result contains all tokens from source1, which do not occur in_source2_.
Array to token string ​
tokstr ( a [, separator ])
Changing an array into a token string. a must be of type array, separator must be of type string with a length of 1 (otherwise the separator is a blank). The result is a text string containing the sequence of array elements which are seperated in the same order as before, separated by separator. Example: tokstr({4711, 4712, 4713}) -> "4711 4712 4713". Example: tokstr({"first", 1.23}, ",") -> "first,1.23".
Hint
The opposite of tokstr() is strarray(): strarray(tokstr(a)) = a:
Array to LEO text token string ​
valtokstr ( a [, separator ])
Conversion of an array into a LEO text token string. a must be of type array, separator must be of type string with a length of 1 (otherwise the separator is a blank). valtokstr() should be used instead of tokstr() if the tokens contain the separator character, or belong to the different types. The result is a string, where all array elements in the same order are separated with separator. Example: valtokstr({"first", 1.23,","}, ",") -> "\ "first\",1.23,\",\"".
Hint
The opposite of valtokstr() is valarray(): valarray(valtokstr(a)) = a:
Token string to array ​
strarray ( str [, separator ])
Conversion of a token string into an array. str and separator must be of type string (separator with a length of 1, otherwise a blank is the separator). The result is an array, where all elements are of type string, containing the tokens in the same sequence as before. Example: strarray("begin 4711 end") -> {"begin", "4711", "end"}.
Hint
The opposite of strarray() is tokstr(): tokstr(strarray(s)) = s:
LEO text token string to array ​
valarray ( str [, separator ])
Conversion of a token string into an array. str and separator must be of type string (separator with a length of 1, otherwise a blank is used as the separator). This function must be used instead of strarray( ) if the tokens are LEO values (strings in apostrophes). For the result, each token is interpreted as a value and all the values are united in one array. Thus, values in an array can be of different types. Example: valarray("4711 4712 4713") -> {4711, 4712, 4713}.
Hint
The opposite of valarray() is valtokstr(): valtokstr(valarray(s)) = s:
Array Operators ​
Operator | Description |
---|---|
a SUB i | a [ i ] | Subscription to an array.a must be of type array, i of the type integer. The result is the i-th element of a. The indexing of the array elements begins with 0. Array elements - as well as the results - can be of any type. The data type of two elements from one array do not have to be the same. Use type() if you are not sure about the element type. For the multidimensional arrays the dimensions can be identified separately. There are two possibilities: a [i,j] or a [i] [j]. Hint: sub is also the subscription operator for strings. |
LEN a | a .length | The length of an array. The parameter a is of the type array; the result is the number of elements of a. Hint: len is also the length operator for strings. |
a .empty | Returns 1 (true) if the array is empty and 0 (false) otherwise. |
a .sort( [lambdaExpr] ) | Sorts the elements of an array. With the optional lambda expression a comparison operator can be specified. The labmda expression must have two parameters and returns true if the first value shall be inserted before the second. The default lamda expression is lambda(x, y, x < y) which leads to an ascending sorting of the array elements. |
Array Functions ​
Function | Description |
---|---|
array ( n1 , ... , nm ) m>=1 | Creates an array with m dimensions and with n elements per dimension. As long as nothing is assigned to an array element, it is of type "undefined". |
areplace ( a , i1 , ... , in , val ) n>=1 | Replaces (sets) an array element. a must be a name of an array variable; the array must have at least n dimensions; all the i values must be of the type integer, but val can be of any type. The return value is val. |
aappend ( a , i1 , ... , in , val ) n>=0 | Appends a value to an array. a must be the name of an array variable. The array must have at least (n+1) dimensions. So, for appending to a one-dimensional array, the function is called with two parameters. val may be of any type. Return value is val. |
ainsert ( a , i1 , ... , in , val ) n>=1 | Inserts an array element at a certain position. |
asinsert ( a , i1 , ... , in , val ) n>=0 | Inserts an element into a sorted array at a position which lets the array still being sorted. |
aerase ( a , i1 , ... , in ) n>=1 | Erases a single array element. a must be the name of an array variable. The array must have at least n dimensions. i1 to in must be of type integer. Return value is the value of the erased element. |
Map Operators ​
Operator | Description |
---|---|
m SUB k | m [ k ] | Subscription to a map.m has to be of type map, k of type string, integer, real, measure or time. The result is the element of m with key k. If the key is not contained in the map, the result is of type undefined. Value elements of a map, and so the result of the subscription, may be of any type. The type of two different value elements of one map needs not to be the same. Use type() if you are not sure about a value element's type. [] is also the subscription operator for arrays. SUB is also the subscription operator for strings and arrays. |
LEN m | m .length | Length (size) of a map. m has to be of type map. The result is the number of elements (key-value pairs) of m. LEN is also the length operator for strings and arrays. |
m .empty | Returns 1 (true) if the map is empty and 0 (false) otherwise. |
m .key( i ) | Returns the key value of the i-th element (key-value pair). i can be from 0 to (the map's length - 1). |
Map Functions ​
Create map ​
map ()
Construction of an empty map. A new map with certain key-value pairs can be constructed like the following: { 1780: "Sim", 1920: "Sala", 2007: "Bim" }
. A key and a related value are separated by a colon ("😊, multiple key-value pairs are separated by comma (","), the set of pairs is enclosed in curly parentheses ("{" and "}").
Non-terminal | Definition |
---|---|
MapValue : | { MapValueContent } . |
MapValueContent : | MapValuePair |
MapValuePair : | OrExpr : OrExpr . |
Erase from map ​
merase ( m,k )
Erases the element with key k from a map m. Return value is the value of element which has been erased.
Unpack to URL query format ​
tourlquerystring ( amap [ , allowed ] )
This function "unpacks" the contents of a map into a URL query string format. It makes it easier to build URL query strings by transforming a map. The map is considered to be shallow, i.e. any of its other structured elements are treated as their string representation. Characters are encoded / escaped using typical URI encoding (%xx
), based on the value of allowed.
The optional allowed parameter specifies all characters that are allowed to appear normally (not encoded) in the result. If allowed is omitted then the same characters are allowed as in the encodeURIComponent()
function from JavaScript. Otherwise it works the same way as in the encodeuri()
function.
Conversion Operators ​
Conversion operators change a quoted value into a value of another type.
Non-terminal | Definition |
---|---|
STR val | Changes a value into a string. Please see the LEO garmmar for the definition of the value. |
VAL str | Changes a string into a numeric value, a measure or a time value. |
CMS measureVal | Changes a measured value into a numerical value in centimetres. Example: CMS 2.3cm = 2.3. |
PTS measureVal | Changes a measured value into a numerical value in points. Example: PTS 10pt = 10. |
CM realVal | Changes a numerical value in centimeters into a measured value. Example: CM 1.23 = 1.23cm. |
PT realVal | Changes a numeric value in points into a measured value. Example: PT 12 = 12pt. |
uistr (val, digits) | Changes a numerical value into a string, taking into consideration the standards of the operating system used (e.g. decimal comma in German, decimal point in English operating systems). digits are used for the number of desired decimal places. Hint: In LEO, floating-point numbers have to be written with a decimal point, not a comma. |
uival (str) | Changes a string into a numeric value taking into consideration the standards of the relevant operating system. |
CHR intVal | Returns the character with the given numerical value. The result depends on the codepage used. Example: CHR 65 = "A". |
ASC str | Delivers the code figure for the characters quoted in str (e.g. ASC "A" = 65). If the quoted string is longer than one character, the value of the first character will be displayed. Note that differences can appear here according to the language and the codepage of the language. Example: ASC "A" = 65. |
INT realVal | Truncates the comma part of a figure (without rounding, e.g. INT 23,999999 = 23). In the case of very large real values, an overflow may occur, which generates a wrong result! |
REAL numVal | Creates a floating-point number from a numerical value (optionally integer or floating-point numbers can be chosen). It is useful with performing calculations with integers, or when the starting type is unclear and the floating-point number must be used. |
toutf8 ( source ) | Konvertiert den normalen Text source in UTF-8-Text. |
fromutf8 ( source ) | Konvertiert den UTF-8-Text source in normalen Text. |
base64encode ( source ) | Converts the normal text source into base64-encoded text. |
base64decode ( source ) | Converts the base64-encoded text source into normal text. |
Color Functions ​
Function | Description |
---|---|
rgbval ( colorname ) | 24-bit RGB color coding with the given color names. The color name can be the plain name (like cornflowerblue), or a 24-Bit-RGB-value (like $6495ed or 16777140). The return type is integer. |
rgbval ( colorname , factor ) | 24-bit RGB color coding with the given color names and additionally a factor for darkening or brightening. A factor of 1.0 refers to the original color, the lower values are used for darker shades and the higher for brighter shades. |
rgbval ( r , g , b ) r, g, b: [0,255] | Creates an integer value from the three components according to the formula 2 ^ 16 * r + 2 ^ 8 * g + b . |
rgb2hsv ( rgb ) | Converts a 3-byte RGB value into a 3-byte HSV value. The return type is integer. |
rgb2hsv ( r , g , b ) r, g, b: [0,255] | Converts the three given RGB values into the 3-byte HSV value. The return type is integer. |
hsvval ( colorname ) | 24-bit HSV color coding with the given color name. The color name can be the plain name (like cornflowerblue), or a 24-bit RGB value (like $6495ed). The return type is integer. |
hsvval ( h , s , v ) h:[0,359], s:[0,1], v: [0,1] | Converts the three given HSV values into the 3-byte HSV value. The return type is integer. |
hsv2rgb ( hsv ) | Converts the 3-byte HSV value into the 3-byte RGB value. The return type is integer. |
hsv2rgb ( h , s , v ) h: [0,359], s: [0,1], v: [0,1] | Converts the HSV components into the 3-byte RGB value. The return type is integer. |
byte ( val , n ) | Extracts the value of the byte with the index n from the composed color values. The lowest byte gets the value 0 (blue in RGB, value/brightness by HSV). The return type is integer. Example: From a RGB value, byte(rgb,2) retuns the red component [0,255], byte(rgb,1) the green component [0,255] and byte(rgb,0) the blue component [0,255]. Example: From a HSV value, byte(hsv,2) / 255.0 * 360.0 returns the color component ("hue") [0,360], byte(hsv,1) / 255.0 the saturation component ("saturation") [0,1] and byte(hsv,0) / 255.0 the brightness ("value") [0,1]. |
Sequence / Comma Operators ​
All expressions of the expressions' sequence (the sequence should be separated through commas) are evaluated and the result of the last expression is returned. These expression sequences are used when a more complicated task is required and multiple expressions need to be used to accomplish it, each building on the last expressions changes (e.g. to while). Should the comma operator in the parameter list of a function call be used, the comma operator contained in the expression must be written in round brackets. Otherwise the comma would be interpreted as a parameter separator.
Example:
fcall (ex1, (ex2, ex3))
leads to a call of
fcall (ex1, ex3).
Assignment Function (set) ​
Syntax:
set ( lvalue , expr )
Assigns a constant or the result of an expression to a variable or an array element.
Condition Function (cond) ​
Syntax:
cond ( cond 1 , expr 1 , ... , cond n , expr n , expr n+1 )n > 0
The parameter number of the cond call has to be an odd number >= 3. The shortest form (n = 1) is cond ( cond 1**,** expr 1**,** expr 2 ).
The parameters cond i quotes the conditions that are checked one after the other. As soon as one condition evaluation is "true", the expression of the condition will be evaluated and the result is returned. Further conditions are not checked anymore. If none of the conditions is evaluated to "true", the result of the last expression is returned. From the entered expr i parameters, exactly one is evaluated in any case. The result can be of integer, double, measure value, time or string types.
Examples:
cond(x > 5, "x is larger than 5", "x is smaller than or equal 5")
cond(x > 5, "x is larger than 5", x < 5, "x is smaller than 5", "x equals 5")
Loop Function (while) ​
Syntax:
while ( cond , loopexpr [ , resultexpr ] )
While the condition cond is true, the expression loopexpr is evaluated. The expression loopexpr must have side effects, so that the condition can become false. The optional resultexpr is evaluated and its result returned when the loop is exited or if cond is already false at the beginning. while(a, b, c) is the same as (while(a, b), c).
Example:
The following expressions calculate the factorial of 5:
set(r, 1), set(i, 1),
while(i <= 5, (set(r, r * i), set(i, i + 1))),
r
Loop Function (for) ​
Syntax:
for ( lvalue , from , to , loopexpr [ , resultexpr ] )
This function evaluates an expression for each value running from one value to another value. The run variable is increased by 1 after each step, until it is larger than the to-value, so the number of loops is (to - from + 1).
Example:
The following code returns "ABCDEFG":
set(s, ""),
for(i, 65, 71, (set(s, s + CHR i))),
s
Loop Function (fortok) ​
Syntax:
fortok ( lvalue , source , separator , loopexpr [ , resultexpr ] )
The variable Ivalue runs through all tokens in source separated by separator. Each run means that loopexpr is evaluated.
if resultexpr is specified, its value will be returned. Otherwise the fortok expression has no result (i.e. a result of type undefined).
Example:
The following expression calculates the factorial of 5:
set(r, 1),
fortok(t, "2 3 4 5", " ", set(r, r * VAL t)),
r
Error Handling (try, error) ​
If errors occur during calculation, the function try() allows for handling them. This function has two parameters. During the calculation, the system tries to evaluate the first parameter. If successful, the result will be returned. If an error occurs, the second parameter is evaluated and the appropriate result is returned.
Example:
In the following code 1 will be returned, if an error like dividing by zero happens:
try(pow(x, y) / (x * y), 1)
The opposite is the function error() which has a string as parameter. It generates the error message with the parameter as the message text.
Lambda Expression (lambda) ​
Syntax:
lambda({ident ,}expr )
A lambda expression is a value and a function. As it is a value, it can be assigned to variables. As it is a function it can be called. A lambda expression can be called like a normal function by appending an (eventually empty) parameter list enclosed in parentheses. The definition of a lambda expression consists of formal parameters and an expression. The formal parameter list is an (eventually empty) list of identifiers. The expression computes something of these parameters.
Example:
The following expression defines a function incr and calls it afterwards. After evaluationg this expression, m has the value m+1:
set(successor, lambda(n, n + 1)), set(m, successor(m))
Without assigning the lambda expression to a value, this could also be written that way:
set(m, lambda(n, n + 1)(m))
In AdoScript it is not possible to define a function with FUNCTION which accesses a global variable. This problem can be solved by assigning a lambda expression to a global variable instead.
Eval Expression (eval) ​
Syntax:
eval( { strOrExprValue } )
eval() makes it possible to create and evaluate expressions dynamically. The passed parameter must be a string or an expression value. If it is a string, the value is at first parsed to an expression value. The expression value which results from the parsing or which has been passed directly is then evaluated in the current context and the result of that evaluation is returned.
Example:
The expression returns the result of STR LEN "STR", which is "3".
set(op, eval("upper(\"str\")")),
set(y, eval(op + "LEN op")),
y
Type Finding (type) ​
Syntax:
type( anyExpr )
With the function type(), the type of an expression can be determined. One of the following values is returned: "string"
, "integer"
, "real"
, "measure"
, "time"
, "expression"
, "array"
, "map"
, "lambda"
, "undefined"
.
Hint
"undefined" refers to a variable that has not been initialised.
Valuation (valofvar) ​
Syntax:
valofvar( strValue )
The function valofvar( ) returns the value of a variable with a given name.
This function is needed if a variable with a name containing minus signs shall be accessed within an expression. If you simply write a variable name with minus signs within an expression, these minus signs would be interpreted as minus operators. Writing a question mark before a variable name has the same effect as calling valofvar() with the variable name in a string.
Hint
"undefined" is a variable which has not been initialised.
Variable List (curvars) ​
Syntax:
curvars()
The function curvars( ) returns a string, containing the names and values of all variables used in the current context. For each variable used, the result contains a line with the format <varname>:<value>. In conjunction with a keyword at the beginning, this is valid LEO text.
Line Numbering (curlineno) ​
Syntax:
curlineno()
The function curlineno( ) provides the line number of the LEO element containing the expression. This function is useful in AdoScripts, to get the currently executed code line. However, it can be used in any LEO code (like GraphRep).
Example:
CC "AdoScript" INFOBOX
("We are now in line no. " + STR curlineno())
Duration Determination (getTickCount) ​
Syntax:
getTickCount()
The function getTickCount( ) returns the time passed (in milliseconds) since the system was started. It is used for example in performance monitoring.
Example:
SET t1:(getTickCount())
CC "AdoScript" SLEEP ms:(3000)
SET t2:(getTickCount())
SET sec:((t2-t1) * 0.001)
CC "AdoScript" INFOBOX ("The calculation took " + STR sec + " seconds.")
Caution
After longs periods of time (several days) the tick count can overflow and become a negative number. When comparing if a certain time has passed fomr a past tick count an expression like the following can be used:
set(tickCount, getTickCount()),
cond((tickCount < 0) AND (lastExec >= 0),
abs(lastExec + tickCount) > delay,
tickCount > (lastExec + delay)
)
Internal Values (internal) ​
Syntax:
internal( strValue )
The function internal() provides access on internal values. By now, these values can be read:
- internal("APPWIN") returns the address (HWND) of the application window.
- internal("TOPWIN") returns the address (HWND) of the top window.
A window address is a value of type long, which can be passed to external DLLs and used there as a parent window for a dialogue.
Example:
Calling an external DLL containing a dialogue via AdoScript
SET hwnd:(internal("APPWIN"))
CALL dll:"extdlg.dll" function:"void showdlg(long hwnd)" hwnd:(hwnd)