DocAda(tm) is a productivity tool of KSCE

Prev | Up | Next | Back | Forward
About DocAda Light: Preface / Preliminary / Help / TOC / Copyright
DocAda Online at the Ada Home: Complete RM95 / Updates / News

5.3 If Statements

An if_statement selects for execution at most one of the enclosed sequences_of_statements, depending on the (truth) value of one or more corresponding conditions.

Syntax

   
       if_statement ::=
           if condition then
             sequence_of_statements
          {elsif condition then
             sequence_of_statements}
          [else
             sequence_of_statements]
           end if;

       condition ::= boolean_expression

Name Resolution Rules

A condition is expected to be of any boolean type.

Dynamic Semantics

For the execution of an if_statement, the condition specified after if, and any conditions specified after elsif, are evaluated in succession (treating a final else as elsif True then), until one evaluates to True or all conditions are evaluated and yield False. If a condition evaluates to True, then the corresponding sequence_of_statements is executed; otherwise none of them is executed.

Examples

Examples of if statements:

   
       if Month = December and Day = 31 then
          Month := January;
          Day   := 1;
          Year  := Year + 1;
       end if;

       if Line_Too_Short then
          raise Layout_Error;
       elsif Line_Full then
          New_Line;
          Put(Item);
       else
          Put(Item);
       end if;

       if My_Car.Owner.Vehicle /= My_Car then            --  see 3.10.1
          Report ("Incorrect data");
       end if;

About DocAda Light: Preface / Preliminary / Help / TOC / Copyright
DocAda Online at the Ada Home: Complete RM95 / Updates / News
Prev | Up | Next | Back | Forward


Copyright © 1994-1997 by Kempe Software Capital Enterprises. All Rights Reserved. For comments on this DocAda(tm) hypertext document, please write to KSCE, at docada@ksce.com