IRAF help page for package language, program if

from NOAO if else -- conditional execution of a statementSYNTAXELEMENTSDESCRIPTIONEXAMPLESSEE ALSO

if else -- conditional execution of a statement


SYNTAX

if (expression) statement1 [else statement2]


ELEMENTS

expression

A boolean valued expression.

statement1, statement2

The statements to be executed (possibly compound, i.e., enclosed in curly braces).


DESCRIPTION

The if statement is used to execute a statement only if the specified condition is true. An optional else clause may be given to execute a different statement if the condition is false.


EXAMPLES

1. Add X to Y only if X is less than Y.

	if (x < y)
	    y += x

2. If X is less than 10 print "small", else print "big".

	if (x < 10)
	    print ("small")
	else
	    print ("big")

3. The else if construct.

	if (str == "+")
	    val += x
	else if (str == "-")
	    val -= x
	else if
	    ...

4. Nesting, use of braces.

	if (i > 0) {
	    if (i < 10) {
		print ("0")
		sum = sum * 10 + i
	    } else
		print (" ")
	}

SEE ALSO

SEE ALSO, for, 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