System Debug Reference Manual (32650-90888)

Chapter 5 173
System Debug Command Specifications Fx-LOG
FOREACH
order to restrict/convert the values in the list to a specific desired type:
foreach j:S16 '1 2 3+4 5' {wl j }
If the type specification is omitted, the type ANY is assumed.
value_list
This is a quoted string (or string variable) that contains a list of values
(expressions). The
cmdlist
is evaluated once for every expression in the
list. The list may contain string and or numeric expressions.
command cmdlist
A single command (or command list) that is executed for each value in
value_list
.
Examples
%cmdebug > foreach j '1 2 3 "MOM" date 12.330' wl j
$1
$2
$3
MOM
WED. SEPT 3, 1986
$12.00000330
A local variable j is assigned each of the expression values in the value list string, and the
specified command references the current value of j in order to write its value.
$nmdebug > foreach j '6 -2 "a" + "b" 3 +4' {wl j}
$4
"ab"
$7
This example shows that full expression values are evaluated within the value list.
$nmdebug > var nums '"1" "2" "3"'
$nmdebug > var lets '"A" "B" "C"'
$nmdebug > foreach l lets { foreach n nums {wl l n }}
A1
A2
A3
B1
B2
B3
C1
C2
C3
This is an example of nested FOREACH commands that use string variables for their value
lists.
Limitations, Restrictions
none