** Next:** How to parse numerical
** Up:** Numeric evaluation of expressions
** Previous:** The expression evaluator
** Contents**
** Index**

###

Substitution of numerical expressions in programs

It is possible to *substitute*
the value of a numerical expression to
this expression in strings of characters. Suppose for instance that you have
a command `defobj1` defining some type of objects (cf. 6), and
want to create objects `p_0`, `p_1`, `p_2`, and so on up
to `n` (a variable). This is the correct way to write it in a program :

do i 0 n
defobj1 p_!(i)
enddo

(for the `do` loop, see 4.8). Here the
numerical expression `i` is converted to an integer, and this integer is
substituted to `!(i)` in the argument. It is possible to put any
kind of numerical expression inside `!()` (for instance `!(i*j+2)`).
It is possible also to substitute
floating point values : if you write

defobj1 p_%(i)

you will obtain `p_0.0000000000000000`, `p_1.0000000000000000`,
and so on up to `n`.

The substitution of numerical expressions is a particular case of the way to
make substitutions in the command interpreter (cf. 4.5).

** Next:** How to parse numerical
** Up:** Numeric evaluation of expressions
** Previous:** The expression evaluator
** Contents**
** Index**
2009-11-12