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 >
Wrap
Text File
|
1991-12-01
|
5KB
|
192 lines
Scripta conditional statements allow the run-time flow of
a script to be varied according to the value of either an
expression or a BOOLEAN function.
The conditional statements are IF, UNLESS, WHILE, UNTIL
and CASE. In the following descriptions of the statements,
the syntax <condition> means any function or expression
which may be evaluated to form a BOOLEAN value (i.e., TRUE
or FALSE). All permitted forms of <condition> are
described at the end of the section, following the
statement descriptions.
IF, UNLESS, WHILE, UNTIL and CASE statements may be nested
to any depth.
IF statements
~~~~~~~~~~~~~
These take the following general form:
IF <condition>
statements
ELSIF <condition>
statements
ELSE
statements
ENDIF
There any be any number of ELSIF elements (including
none).
If the IF condition evaluates to TRUE then the statements
following the IF statement are executed until an ELSIF,
ELSE or ENDIF statement is encountered. If the encountered
statement is not an ENDIF statement, statements are then
skipped until ENDIF is encountered.
If the IF condition is FALSE then statements following the
IF statement are ignored until an ELSIF, ELSE or ENDIF
statement is encountered. If an ELSIF statement is
encountered then its condition is evaluated and acted upon
just as though this were a brand new IF statement.
When statements are being skipped, because a FALSE
condition has been evaluated in an IF or ELSIF statement,
then if an ELSE statement is encountered then the
statements following ELSE are executed until ENDIF is
encountered.
UNLESS Statements
~~~~~~~~~~~~~~~~~
A statement of the form
UNLESS <condition>
is exactly equivalent to a statement of the form
IF NOT <condition>.
An UNLESS statement may have ELSIF and ELSE clauses, just
like an IF statement, and is terminated by an ENDIF
statement.
WHILE Statements
~~~~~~~~~~~~~~~~
These take the general form
WHILE <condition>
statements
ENDWHILE
The statements between WHILE and ENDWHILE are executed
zero or more times as long as <condition> evaluates to
TRUE.
If the condition is initially FALSE then the statements
will not be executed at all. Whenever the ENDWHILE
statement is reached, the WHILE condition is tested again
and, if still TRUE, the statements are executed once
again.
UNTIL Statements
~~~~~~~~~~~~~~~~
These take the general form
UNTIL <condition>
statements
ENDUNTIL
The statements between UNTIL and ENDUNTIL are executed
zero or more times as long as <condition> evaluates to
FALSE.
The statement
UNTIL <condition>......ENDUNTIL
is exactly equivalent to the statement
WHILE NOT <condition>......ENDWHILE.
CASE Statements
~~~~~~~~~~~~~~~
The general form of a CASE statement is
CASE <base_expression>
CASEOF <expression_1>
statements_1
CASEOF <expression_2>
statements_2
.
.
.
CASEOF <expression_n>
statements_n
ENDCASE
There may be any number of CASEOF clauses each comprising
a CASEOF statement followed by zero or more Scripta
commands and statements.
The CASE statement causes execution of the first
encountered CASEOF clause whose expression element
evaluates exactly to the value of the CASE base expression.
If no such CASEOF clause is encountered then the CASE
statement has no effect at all.
The CASE expression and the CASEOF expressions may be ANY
valid Scripta expressions.
Note in particular that the CASE <base_expression> may be
ANY expression; it need not be a simple variable name.
Therefore, take care to remember the rules for the
formation of expressions when writing CASE statements. For
example, if the Scripta variables %a and %b currently have
the values "123" and "456" respectively, then
CASE %a+%b executes the CASEOF clause whose
expression element elaborates to
the INTEGER value 579.
CASE "%a+%b" executes the CASEOF clause whose
expression element elaborates to
the STRING value "123+456".
One of the CASEOF expressions may take the special value
OTHER which always evaluates to the same value as the CASE
base expression. This allows a CASEOF clause to be
provided for a general or default value of the base
expression, not catered for by the other CASEOF clauses.
For example, consider the following script fragment:
%fname := "MYFILE.DAT"
%done := FALSE
While not %done
%done := TRUE
GETKEY %a %b
$CAPS %a
CASE "%a"
CASEOF "E"
Erase %fname
CASEOF "D"
Shell "!TYPE %fname|more"
CASEOF OTHER
Message "You must press E or D."
%done := FALSE
ENDCASE
EndWhile
This script fragment loops continually until an E or D
character is pressed on the keyboard. E causes the file
MYFILE.DAT to be erased; D causes a shell to DOS to
execute a TYPE command to display MYFILE.DAT; any other
character generates a message telling you that you have
typed an illegal character.