Passing parameters

Parameters can be passed in different brackets, which determine the way the parameter is handled:

{code} - execution of the code parameter occurs every time it is referred to within the called method;
(expression) - the value of the expression in the parameter is calculated every time it is referred to within the called method;
[code]- execution of the code parameter occurs once before the method call.

An example to demonstrate difference between brackets:
@main[]
$a(20)
$b(10)
^sum[^
eval($a+$b)]
<hr />
^sum{^eval($a+$b)}

@sum[c]
^
for[b](100;110){
   $c
}[
<br />]

As you can see, in the first case the code was calculated only once-before method
sum was called-and the method received the result of this calculation-number 30. In the second case the code was executed every time the parameter was referred to-that is why the result was different each time, depending on the counter's value.

There can be many parameters or none. If you place many parameters inside single-type brackets, they can be separated by semicolon. Any combination of different types of parameters is allowed.

For example, the construction...
    ^if(condition){when true;when false}
...is equal to...
    ^if(condition){when true}{when false}


Copyright © 1997–2025 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 17.04.2024