http://www.cise.ufl.edu/~mssz/Pascal-CGS2462/ifs-and-loops.html
-------------------------------------------------
4.2. PASCAL Selection Structures.
The PASCAL language provides IF or BLOCK-IF constructs, where the
latter is a variation of the IF statement, as discussed in Section
3.1. We define these statements as follows:
IF..THEN..ELSE statement:
Purpose: The IF statement provides a mechanism for decision based on a
logical predicate.
Syntax: IF predicate THEN actions-if-predicate-is-true
ELSE actions-if-predicate-is-false ; , where
actions-if-predicate-is-true are one or more PASCAL statements
actions-if-predicate-is-false are one or more PASCAL statements
Example:
IF ((score > 90) AND (score <= 100)) THEN
grade := 'A'
ELSE
WRITELN('You did not get an A')
;
Notes: When single statements are used in an IF statement block, one
must take care not to put a semicolon after the statement that follows
the IF...ELSE block. Otherwise, the PASCAL compiler will infer that
the IF statement should be terminated at the semicolon. So, the
semicolon goes after the ELSE predicates, as shown above. When the IF
statement is used to execute large blocks of compound statements, then
the BEGIN..END construct should be used to delimit those statement
blocks.
IF..THEN..ELSEIF..THEN..ELSE (Block-IF) statement:
Purpose: The Block-IF statement provides a mechanism for decision
based on multiple logical predicates. This can be useful for grouping
data items into prespecified categories.
Syntax: IF predicate1 THEN actions-if-predicate1-is-true
ELSEIF predicate2 THEN
actions-if-predicate2-is-true
:
ELSEIF predicateN THEN
actions-if-predicateN-is-true
ELSE actions-if-predicates-are-false ; , where
actions-if-predicate-is-true are one or more PASCAL statements
actions-if-predicate-is-false are one or more PASCAL statements
Example:
IF ((score > 90) AND (score <= 100)) THEN
grade := 'A'
ELSEIF ((score > 80) AND (score <= 90)) THEN
grade := 'B'
ELSEIF ((score > 70) AND (score <= 80)) THEN
grade := 'C'
ELSEIF ((score > 60) AND (score <= 70)) THEN
grade := 'D'
ELSE
WRITELN('You got an E')
;
PASCAL also supports nested decision structures, in which an IF
statement contains other IF statements in its list of executable
statements. This allows the programmer to specify decisions based on
concepts or criteria that are hierarchically structured.
------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
mseide-msegui-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk