next up previous contents
Next: User's reference Up: Basics of data management Previous: Commandsswitches, scripts and

Variables and parameter substitution

 

Variables and script parameters are denoted in a similar way as in UNIX command interpreters (shells). A $-sign should precede either a single number or a brace-delimited structure, such as {nn}, {name} or {name[${ind}]}. Numbers refer to parameters passed to the currently running script file and names refer to data (or names of data fields within frames) stored in the name space.

To be able to refer to a certain data value within a data field, indexes can be used. Indexes can also be used to get the name of a certain field from a data frame or classified data. Indexes are delimited with brackets. An index should be a numeric constant or a variable.

The substitution is performed recursively and therefore the name part of
${name[${ind}]} can be replaced with $1, for example.

Examples:

Parameter reference Description
$2 2nd parameter of the script invocation command line
${12} 12th parameter on the command line
${ind} First (index 0) value of data field (or variable) ind
${${ind}\} indth parameter on the command line
${fld[${ind}]} indth value of field fld
${frm[${ind}]} Name of the indth field of frm
${frm.f1[${ind}]} indth value of field frm.f1
${$1[${ind}]} indth value of field (or indth field name of frame) $1

The number of available parameters can be obtained with $?, and $* can be used to put all specified parameters into the new command line.

For an additional example, see the while command (section 9.2).


next up previous contents
Next: User's reference Up: Basics of data management Previous: Commandsswitches, scripts and

Anssi Lensu
Thu May 17 15:00:44 EET DST 2001