parent
7263f2e19a
commit
5d9764dd69
|
@ -10141,8 +10141,8 @@ Macro expressions
|
||||||
|
|
||||||
It is possible to construct macro-expressions which can be assigned to
|
It is possible to construct macro-expressions which can be assigned to
|
||||||
macro-variables or used within a macro-directive. The expressions are
|
macro-variables or used within a macro-directive. The expressions are
|
||||||
constructed using literals of the four basic types (integers, strings,
|
constructed using literals of five basic types (integers, strings,
|
||||||
arrays of strings, arrays of integers), macro-variables names and
|
arrays of strings, arrays of integers, and string functions), macro-variables names and
|
||||||
standard operators.
|
standard operators.
|
||||||
|
|
||||||
String literals have to be enclosed between **double** quotes (like
|
String literals have to be enclosed between **double** quotes (like
|
||||||
|
@ -10186,6 +10186,11 @@ The following operators can be used on arrays:
|
||||||
``1:length(["a", "b", "c"])`` is equivalent to integer array
|
``1:length(["a", "b", "c"])`` is equivalent to integer array
|
||||||
``[1,2,3]``)
|
``[1,2,3]``)
|
||||||
|
|
||||||
|
The following operators can be used on string functions:
|
||||||
|
|
||||||
|
* Comparison operators: ``==``, ``!=``
|
||||||
|
* Concatenation of two strings: ``+``
|
||||||
|
|
||||||
Macro-expressions can be used at two places:
|
Macro-expressions can be used at two places:
|
||||||
|
|
||||||
* Inside macro directives, directly;
|
* Inside macro directives, directly;
|
||||||
|
@ -10237,18 +10242,20 @@ Macro directives
|
||||||
|
|
||||||
.. macrodir:: @#define MACRO_VARIABLE = MACRO_EXPRESSION
|
.. macrodir:: @#define MACRO_VARIABLE = MACRO_EXPRESSION
|
||||||
|
|
||||||
|br| Defines a macro-variable.
|
|br| Defines a macro-variable or macro function.
|
||||||
|
|
||||||
*Example*
|
*Example*
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
@#define x = 5 // Integer
|
@#define x = 5 // Integer
|
||||||
@#define y = "US" // String
|
@#define y = "US" // String
|
||||||
@#define v = [ 1, 2, 4 ] // Integer array
|
@#define v = [ 1, 2, 4 ] // Integer array
|
||||||
@#define w = [ "US", "EA" ] // String array
|
@#define w = [ "US", "EA" ] // String array
|
||||||
@#define z = 3 + v[2] // Equals 5
|
@#define z = 3 + v[2] // Equals 5
|
||||||
@#define t = ("US" in w) // Equals 1 (true)
|
@#define t = ("US" in w) // Equals 1 (true)
|
||||||
|
@#define f(x) = " + @{x} + @{y}" // Defines a function 'f' with argument 'x'
|
||||||
|
// that resturns the string ' + @{x} + US'
|
||||||
|
|
||||||
*Example*
|
*Example*
|
||||||
|
|
||||||
|
@ -10256,15 +10263,16 @@ Macro directives
|
||||||
|
|
||||||
@#define x = [ "B", "C" ]
|
@#define x = [ "B", "C" ]
|
||||||
@#define i = 2
|
@#define i = 2
|
||||||
|
@#define f(x) = " + @{x}"
|
||||||
|
|
||||||
model;
|
model;
|
||||||
A = @{x[i]};
|
A = @{x[i]+f("D")};
|
||||||
end;
|
end;
|
||||||
|
|
||||||
The latter is strictly equivalent to::
|
The latter is strictly equivalent to::
|
||||||
|
|
||||||
model;
|
model;
|
||||||
A = C;
|
A = C + D;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue