FOR, FOREACH

Command looping facility.

SYNOPSIS

[ foreach | for ] name ( list )
commands
end

DESCRIPTION

The for command allows the user to specify loops in the input. Either for or foreach is acceptable. name will take on the values in the list consecutively until the there are no values left. The body will be executed once for each value in the list. Values in the list can be separated by commas or spaces. name is set to the value in the list using the define feature of the shell. Replacement of name in the body of the commands is done using the macro features that are part of the normal shell.

The list is a set of strings separated by commas or spaces. It can also be one of the following numerical operators:

start to end step val

where start is a numerical start value, end is the last value, and val is the size of step to take between them.

EXAMPLES

foreach string ( hello, goodbye, aufwiedersehn, goodnight )
echo string
end

The command "echo string" will be executed four times. string will be set to the values "hello", "goodbye", "aufwiedersehn", and "goodnight" consecutively. This will produce output that will look something like:

hello
goodbye
aufwiedersehn
goodnight

foreach val ( 1.0 to 10.0 step 0.5 )
echo val
end

This will increment val from 1.0 to 10.0 in steps of 0.5. The inner body of the loop will be executed 19 times.

BUGS

Any bugs in the define code and macro handlers will probably show up here.

SEE ALSO

The define command.