home *** CD-ROM | disk | FTP | other *** search
/ Shareware 1 2 the Maxx / sw_1.zip / sw_1 / COMM / SCR104A.ZIP / SCRHELP.EXE / CONDSTAT < prev    next >
Text File  |  1991-12-01  |  5KB  |  192 lines

  1. Scripta conditional statements allow the run-time flow of
  2. a script to be varied according to the value of either an
  3. expression or a BOOLEAN function.
  4.  
  5. The conditional statements are IF, UNLESS, WHILE, UNTIL
  6. and CASE. In the following descriptions of the statements,
  7. the syntax <condition> means any function or expression
  8. which may be evaluated to form a BOOLEAN value (i.e., TRUE
  9. or FALSE). All permitted forms of <condition> are
  10. described at the end of the section, following the
  11. statement descriptions.
  12.  
  13. IF, UNLESS, WHILE, UNTIL and CASE statements may be nested
  14. to any depth.
  15.  
  16. IF statements
  17. ~~~~~~~~~~~~~
  18. These take the following general form:
  19.  
  20. IF <condition>
  21.  
  22.    statements
  23.  
  24. ELSIF <condition>
  25.  
  26.    statements
  27.  
  28. ELSE
  29.  
  30.    statements
  31.  
  32. ENDIF
  33.  
  34. There any be any number of ELSIF elements (including
  35. none).
  36.  
  37. If the IF condition evaluates to TRUE then the statements
  38. following the IF statement are executed until an ELSIF,
  39. ELSE or ENDIF statement is encountered. If the encountered
  40. statement is not an ENDIF statement, statements are then
  41. skipped until ENDIF is encountered.
  42.  
  43. If the IF condition is FALSE then statements following the
  44. IF statement are ignored until an ELSIF, ELSE or ENDIF
  45. statement is encountered. If an ELSIF statement is
  46. encountered then its condition is evaluated and acted upon
  47. just as though this were a brand new IF statement.
  48.  
  49. When statements are being skipped, because a FALSE
  50. condition has been evaluated in an IF or ELSIF statement,
  51. then if an ELSE statement is encountered then the
  52. statements following ELSE are executed until ENDIF is
  53. encountered.
  54.  
  55. UNLESS Statements
  56. ~~~~~~~~~~~~~~~~~
  57. A statement of the form
  58.  
  59.                UNLESS <condition>
  60.  
  61. is exactly equivalent to a statement of the form
  62.  
  63.                IF NOT <condition>.
  64.  
  65. An UNLESS statement may have ELSIF and ELSE clauses, just
  66. like an IF statement, and is terminated by an ENDIF
  67. statement.
  68.  
  69. WHILE Statements
  70. ~~~~~~~~~~~~~~~~
  71. These take the general form
  72.  
  73. WHILE <condition>
  74.  
  75.    statements
  76.  
  77. ENDWHILE
  78.  
  79. The statements between WHILE and ENDWHILE are executed
  80. zero or more times as long as <condition> evaluates to
  81. TRUE.
  82.  
  83. If the condition is initially FALSE then the statements
  84. will not be executed at all. Whenever the ENDWHILE
  85. statement is reached, the WHILE condition is tested again
  86. and, if still TRUE, the statements are executed once
  87. again.
  88.  
  89. UNTIL Statements
  90. ~~~~~~~~~~~~~~~~
  91. These take the general form
  92.  
  93. UNTIL <condition>
  94.  
  95.    statements
  96.  
  97. ENDUNTIL
  98.  
  99. The statements between UNTIL and ENDUNTIL are executed
  100. zero or more times as long as <condition> evaluates to
  101. FALSE.
  102.  
  103. The statement
  104.  
  105.         UNTIL <condition>......ENDUNTIL
  106.  
  107. is exactly equivalent to the statement
  108.  
  109.         WHILE NOT <condition>......ENDWHILE.
  110.  
  111. CASE Statements
  112. ~~~~~~~~~~~~~~~
  113. The general form of a CASE statement is
  114.  
  115. CASE <base_expression>
  116. CASEOF <expression_1>
  117.  
  118.    statements_1
  119.  
  120. CASEOF <expression_2>
  121.  
  122.    statements_2
  123.  .
  124.  .
  125.  .
  126.  
  127. CASEOF <expression_n>
  128.  
  129.    statements_n
  130.  
  131. ENDCASE
  132.  
  133. There may be any number of CASEOF clauses each comprising
  134. a CASEOF statement followed by zero or more Scripta
  135. commands and statements.
  136.  
  137. The CASE statement causes execution of the first
  138. encountered CASEOF clause whose expression element
  139. evaluates exactly to the value of the CASE base expression.
  140. If no such CASEOF clause is encountered then the CASE
  141. statement has no effect at all.
  142.  
  143. The CASE expression and the CASEOF expressions may be ANY
  144. valid Scripta expressions.
  145.  
  146. Note in particular that the CASE <base_expression> may be
  147. ANY expression; it need not be a simple variable name.
  148. Therefore, take care to remember the rules for the
  149. formation of expressions when writing CASE statements. For
  150. example, if the Scripta variables %a and %b currently have
  151. the values "123" and "456" respectively, then
  152.  
  153.      CASE %a+%b        executes the CASEOF clause whose
  154.                        expression element elaborates to
  155.                        the INTEGER value 579.
  156.  
  157.      CASE "%a+%b"      executes the CASEOF clause whose
  158.                        expression element elaborates to
  159.                        the STRING value "123+456".
  160.  
  161. One of the CASEOF expressions may take the special value
  162. OTHER which always evaluates to the same value as the CASE
  163. base expression. This allows a CASEOF clause to be
  164. provided for a general or default value of the base
  165. expression, not catered for by the other CASEOF clauses.
  166.  
  167. For example, consider the following script fragment:
  168.  
  169. %fname := "MYFILE.DAT"
  170. %done := FALSE
  171. While not %done
  172.    %done := TRUE
  173.    GETKEY %a %b
  174.    $CAPS %a
  175.    CASE "%a"
  176.    CASEOF "E"
  177.       Erase %fname
  178.    CASEOF "D"
  179.       Shell "!TYPE %fname|more"
  180.    CASEOF OTHER
  181.       Message "You must press E or D."
  182.       %done := FALSE
  183.    ENDCASE
  184. EndWhile
  185.  
  186. This script fragment loops continually until an E or D
  187. character is pressed on the keyboard. E causes the file
  188. MYFILE.DAT to be erased; D causes a shell to DOS to
  189. execute a TYPE command to display MYFILE.DAT; any other
  190. character generates a message telling you that you have
  191. typed an illegal character.
  192.