IF
if_statement
[ if _label : ] if condition then sequence_of_statements { elsif condition then sequence_of_statements } [ else sequence_of_statements ] end if [ if _label ] ;
Parents
- function_statement_part
- procedure_statement_part
- process_statement_part
Further definitions
label
condition
boolean _expression
sequence_of_statements
Examples
If a has the value 1 then b is assigned the value 0 .
IF a = '1' THEN b := '0' ; END IF ;
If the value of a is bigger than 0 then b is assigned the value of a, otherwise that of ABS ( a + 1 ).
IF a > 0 THEN b := a ; ELSE b := ABS ( a + 1 ) ; END IF ;
This is an example of a complete IF - ELSIF -loop. The conditions are checked one after the other. When the first match is found the relevant actions are carried out and the IF -loop is left.
IF val >= 5 AND val < 10 THEN int := 7 ; ELSIF val < 5 THEN int := val + func( val + 2 ) ; ELSIF val < 15 THEN int := func( val ) ; ELSE int := 0 ; END IF ;