INCLAN: if: Difference between revisions

From CYANA Wiki
Jump to navigation Jump to search
m (1 revision)
No edit summary
Line 1: Line 1:
== Synopsis ==


Usage: if (''condition'') ''command'' {''parameter''}
'''if''' (''condition'') ''statement''
      if (''condition'') then
 
        .
'''if''' (''condition'') '''then'''<br>
        .
.<br>
      else if (''condition'') then
.<br>
        .
else if (''condition'') then<br>
        .
.<br>
      else
.<br>
        .
else<br>
        .
.<br>
      end if
.<br>
end if
 
== Description ==


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


Example: if (i.gt.0) then
== Examples==
          print "$i is greater than 0."
 
        else if (def('''x''') .and. exist('''y''')) then
i=–56
          print "The variable x is defined, and the variable y exists."
if (i.lt.0) print "$i is negative."
        else if (string.ne.''' ''') then
–56 is negative.
          print "The variable string has the non-blank value $string."
 
          if (mod(j,2).eq.1) print "j is odd."
if (mod(i,2).eq.1) then
        end if
  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

Revision as of 17:26, 13 August 2009

Synopsis

if (condition) statement

if (condition) then
.
.
else if (condition) then
.
.
else
.
.
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