IRAF help page for package language, program for

from NOAO for -- FOR statementSYNTAXELEMENTSDESCRIPTIONEXAMPLESBUGSSEE ALSO

for -- FOR statement


SYNTAX

for ([assign1] ; [bool_expr] ; [assign2]) statement


ELEMENTS

assign1

An assignment used to initialize the for loop.

bool_expr

A boolean valued expression tested before each iteration.

assign2

An assignment executed after each iteration of the loop.

statement

A statement (possibly compound, i.e., enclosed in curly brackets) to be executed in each iteration of the loop.


DESCRIPTION

The for statement provides a looping mechanism similar to the C-language for loop. Assign1 and assign2 are assignment statements using one of the operators '=', '+=', '-=', '/=', '*='. Any of the elements of the for loop may be omitted, except the parenthesis and colon field delimiters.


EXAMPLES

1. For I equals zero to 10 in steps of 2, increment TOTAL by the value of array element I.

	for (i=0;  i <= 10;  i += 2)
	    total += array[i]

2. Print the first eight powers of two.

	j = 1
	for (i=1;  i <= 8;  i += 1) {
	     print (i, j)
	     j *= 2
	}

BUGS

BUGS A simple assignment of the form i++ will not work. Only one assigment statement is permitted in the first and third fields.


SEE ALSO

while, case, break, next,


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