INCLAN: if: Difference between revisions

From CYANA Wiki
Jump to navigation Jump to search
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:


'''if''' (''condition'') ''statement''
'''if''' (''condition'') ''statement''
or


'''if''' (''condition'') '''then'''<br>
'''if''' (''condition'') '''then'''<br>
.<br>
:''sequence of statements''
.<br>
'''else if''' (''condition'') '''then'''<br>
else if (''condition'') then<br>
:''sequence of statements''
.<br>
'''else'''<br>
.<br>
:''sequence of statements''
else<br>
'''end if'''
.<br>
.<br>
end if


== Description ==
== Description ==
Line 19: Line 18:
statements. A logical "if" statement must not end with the word "then".
statements. A logical "if" statement must not end with the word "then".


== Examples==
== Examples ==


  i=–56
  i=–56

Latest revision as of 10:45, 17 August 2009

Synopsis

if (condition) statement

or

if (condition) then

sequence of statements

else if (condition) then

sequence of statements

else

sequence of statements

end if

Description

The "if" statement allows for Fortran-77 style logical or block if statements. A logical "if" statement must not end with the word "then".

Examples

i=–56
if (i.lt.0) print "$i is negative."
–56 is negative.
if (mod(i,2).eq.1) then
  print "$i is an odd number."
else if (def(’x’) .and. exist(’y’)) then
  print "x is defined, and y exists."
else if (s.eq.’ ’) then
  print "The variable s is blank."
end if