IRAF help page for package language, program break

from NOAO break -- break out of a loopUSAGEDESCRIPTIONEXAMPLESBUGSSEE ALSO

break -- break out of a loop


USAGE

break


DESCRIPTION

The break statement is used to exit (break out of) the for or while loop in which it is found. In the case of nested loop constructs only the innermost loop is terminated. Unlike C usage the break statement does not break out of a switch.


EXAMPLES

1. Scan a list (file), printing each list element until either the list is exhausted or a list element "exit" or "quit" is encountered.

	while (fscan (list, s1) != EOF) {
	    if (s1 == "exit" || s1 == "quit")
		break
	    print (s1)
	}

2. Sum the pixels in a two dimensional array, terminating the sum for each line if a negative pixel is encountered, and terminating the entire process when the total sum passes a predefined limit.

	total = 0
	for (i=1;  i <= NCOLS;  i+=1) {
	    for (j=1;  j <= NLINES;  j+=1) {
		if (pixel[i,j] < 0)
		    break		# exit the J loop
		total += pixel[i,j]
	    }
	    if (total > NPHOT)
		break			# exit the I loop
	}

BUGS

BUGS


SEE ALSO

next, while, for,


This page automatically generated from the iraf .hlp file. If you would like your local iraf package .hlp files converted into HTML please contact Dave Mills at NOAO.

dmills@noao.edu