break

Syntax break

Action Terminates the innermost for, loop, fileloop, or while statement in which it is contained. Script execution continues at the next statement following the looping construct, skipping any subsequent statements within the current loop body.

Examples fileloop (fName in folderPath)
if file.isLocked (fName)

lockedFileFound = true

break

++numberOfFiles

if lockedFileFound
msg ("Found a locked file.")

This is just a script fragment, so don't attempt to execute it. A loop like the one above might be used to count the number of files in a folder about to be deleted, so that a confirmation dialog could be presented to the user. However, since a locked
file was found, the folder cannot be deleted, and the loop is terminated early.

loop
if not dialog.ask ("What number am I thinking of?", @x)

return (false)

if x == 16396

break

msg ("Try again!")

This is just a script fragment, so don't attempt to execute it. This loop prompts the user for a number forever, until he or she exhibits astonishing clairvoyance or gets sick of the game. The break statement allows the loop to be terminated if the user
gets lucky.

Notes The break statement only terminates the loop that contains it; loops outside of the innermost loop continue to execute as usual.

See Also for

fileloop

loop

while

continue

Discuss