[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.5 Variable Name Substitution

A very powerful feature of scripting languages like Tcl and Perl is that they can use expressions to create or reference variables at run time. In other words, the variable name (or part of it) is itself a variable, and only at runtime does the system know the actual variable name.

Bunao supports variable name substitution. It is performed by appending a expression to a variable name in matching single quotes (``' and `'').

When Bunao sees an expression with a ``...'' construction, it first evaluates the material inside the single quotes, and then replaces the quoted expression with the result of that evaluation. It now re-evaluates the result, using the new name.

For example, if the variable x had been set to the string `bar', then this expression:

foo`x'

refers to the variable foobar. Similarly, if y was set to `5', then this expression:

foo`y+1'

refers to the variable foo6.

Variable name substitution can also be used on array names. If the value of i is `5', then this expression

A`i'(j)

refers to the array element A5(j).



This document was generated on October, 28 2005 using texi2html