Conditional processing—"if"

if statement else statement You may want to vary the content or format of your report based on actual data in table columns (or variables). To do so, use "if" statements.  <"if" <test>
— statements executed if <test> is true —
"else"
— statements executed if <test> is false —
"end" 〈"if"〉 where
\begin{List}
\item[<test>] is a normal ''where'' clause (without the
\lq\lq where''). It may contain columns from the current table,
variables, and values.
\end{List}

The <test> is evaluated. If it is true, the statements following "if" are executed and the statements following "else" are skipped. If it is false, the statements following "if" are skipped and the statements following "else" are executed. The "else" and following statements are optional.


This report program

*(    Rim report of resistance measurements by conductor )
report
 
  header
    1  5 'Resistance measurements by conductor'
    1 60 'Page: '
    1 66 page_number i5
    2 1 ' '
    3 1 'Symbol    No.    Name         Resistivity'
    4 1 ' '
  end
 
  select from conductors
    print
      1 1 symbol a8
      1 10 at_no i4
      1 16 name a15
      1 32 resistivity f6.2
    end print
    xsym 8 = symbol
    mline = 0
    mrest real = 0
 
    rem  select all measurements for this conductor
 
    select from measures where symbol = xsym
      mline = mline + 1
      if mline = 1  *(print the sub-header)
        print
          2 5 '   id   date               resistivity'
          3 5 '-----  --------            -----------'
        end print
      end if
      print
        1 5 id i5
        1 12 m_date 'yy/mm/dd'
        1 32 resistivity f6.2
      end print
      mrest = mrest + resistivity
    end select
 
    rem print a summary for each conductor
 
    if mline > 0
      mrest = mrest / mline
      print
        2 10 'Measured resistivity = '
        2 32 mrest f6.2
        3 1 ' '          *( one blank line following summary)
      end print
    else
      print
        2 10 'No measurements taken'
        3 1 ' '
      end print
    end if
 
  end select
 
end report

prints the following report

==29pc

     Resistance measurements by conductor                   Page:     1
 
 Symbol    No.    Name         Resistivity
 
 Cu         29  Copper            0.12
 
        id   date               resistivity
     -----  --------            -----------
         5  88/01/21             11.90
         5  88/01/21             12.40
        22  88/02/22             12.50
 
          Measured resistivity = 12.27
 
 Al         13  Aluminum          0.18
 
        id   date               resistivity
     -----  --------            -----------
        35  88/02/10             13.00
        35  88/02/10             14.30
 
          Measured resistivity = 13.65
 
 Fe         26  Iron              0.24
 
        id   date               resistivity
     -----  --------            -----------
         5  88/03/04             19.40
 
          Measured resistivity = 19.40
 
 LB       -MV-  Bernstein         -MV-
 
          No measurements taken
 
 U          92  Uranium           0.44
 
          No measurements taken
\fbox{\fbox{\box\Rimdemobox}}