Tools: MPW
Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Support

MPW Command Reference


Loop…End

Built-in

SYNTAX

Loop
  command1
  [command2]…
End

DESCRIPTION

The Loop…End control structure executes the enclosed commands until a Break command terminates the loop. You can use the Continue command to terminate the current iteration of the loop.

The pipe specification (|), conditional command terminators (&& and ||), and input or output specifications (<, >, >>, ≥, ≥≥, ∑, and ∑∑) can appear following the End statement and apply to all the commands in the list.

INPUT

None

OUTPUT

None

STATUS

Loop returns the status of the last command executed.

PARAMETERS

command1 [command2]…

Specifies a list of one or more commands. Multiple commands must be separated by either newline characters or semicolons.

OPTIONS

None

EXAMPLES

By executing a simple loop, the script

Set n 1
Loop
  Break If {n} > 3
  Echo {n}
  Evaluate n +=1
End

produces this output:

1
2
3

The following script runs a command several times, once for each parameter. Notice that Shift is used to step through the parameters, and that Break ends the loop when all parameters have been used.

Set cmd "{1}"
Loop
  Shift
  Break If "{1}" == ""
  {cmd} "{1}"
End

SEE ALSO

Break

Continue

For…

 
 


Last Updated July 2000