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

MPW Command Reference


Break

Built-in

SYNTAX

Break [If expression]

DESCRIPTION

The Break command terminates execution of the immediately enclosing For or Loop control structure if expression evaluates to TRUE (nonzero). If you omit If expression, the loop breaks unconditionally.

INPUT

None

OUTPUT

None

STATUS

Break can return the following status codes:

0

no errors

-3

break found outside For…End or Loop…End; or incorrect parameters

-5

invalid expression

PARAMETERS

expression

Specifies an expression of the form

operand operator operand

If this expression evaluates to TRUE (nonzero), the loop breaks. (For a more detailed definition of expression, see the Evaluate command.)

OPTIONS

None

EXAMPLES

The following command line terminates execution of the enclosing loop if the previous command returns a nonzero status value. See the next example for a sample of how this command line can be used in scripts.

Break If {Status} != 0

In this example, the For loop entabs and prints each of the special MPW scripts. The loop is terminated by Break if Entab returns a nonzero status value. See the For… command for further explanation of this example.

Set Exit 0
For file in Startup UserStartup Suspend Resume Quit
  EnTab "{file}" > temp
  Break If {Status} != 0
  Rename -y temp "{file}"
  Print -h "{file}"
  Echo "{file}"
End

The script below loops until the variable {loopcount} returns a value greater than 10. Note the use of the Evaluate command (line 5).

Set loopCount 0
Loop
  Break If {loopCount} > 10
  Echo "Loop Number {loopCount}"
  Evaluate loopCount +=1
End

SEE ALSO

Evaluate

For…

If…

Loop

 
 


Last Updated July 2000