Script language

The script language is most similar to Modula-2 in appearance.However Ada95 and Pascal programmers will feel quite at home. A script file shellis as follows:

SCRIPT scriptName;

BEGIN

END scriptName.

The script starts with the word SCRIPT followed by the script'sname.  Then a BEGIN statement and the script is completed with an END (followedby the script"s name). The script "code" to be executed appears betweenthe BEGIN and END tokens.  The script language consists of IF statements, %INCLUDEstatements, built-in procedures (functions), and comments.  The built-in procedureshave parameters including built-in enumerated types, string literals, and numerictypes.

The script language is not case sensitive. For instance, thefollowing names are the same:

Begin           BEGIN

String Literals

String literals are strings of characters enclosed in singleor double quote characters (" or ').

Examples:

"This is a string"

"Here's another string"

Comments

Comments have no effect on the meaning of a script.  Theyprovide only additional information to aid in the understanding of a script. Commentsare delimited by the symbols (* and *).  They can occur between any two tokens. Comments can be nested; that is, they can contain other comments.

Examples:

(* Comments look like this *)

(* A  (* nested  *) comment looks like this *)

IF Statements

The IF statement conditionally executes one or more sequencesof statements based on the values of expressions. The format of the IF statementis:

IF BooleanExpression THEN

    {Statement}

[ELSIF BooleanExpression THEN

    {Statement}]

[ELSE

    {Statement}]

END

where:

BooleanExpression is one or more Boolean Functions in combinationwith AND, OR, and NOT Boolean operators. You may also use parentheses to logicallyorder the expression.

The Boolean operators AND, OR and NOT respectively perform Booleanconjunction, Boolean disjunction, and Boolean negation (identically to Boolean operatorsin Modula-2 and Pascal. For Ada95 AND behaves like and then, and OR behaves likeor else). Operator precedence is from highest to lowest.

NOT

AND

OR

The BooleanExpression is evaluated as follows:

If the value of the expression is TRUE, the Statement(s) followingthe word THEN is executed, after which control is transferred to the statement followingthe IF statement.

If the expression if FALSE and there are ELSIF clauses, theneach ELSIF BooleanExpression is evaluated until one is found that is TRUE. The Statement(s)following the TRUE BooleanExpression is then executed and control is transferredto the statement following the IF statement.

If no BooleanExpression is TRUE, and there is an ELSE clause,the Statement(s) following the ELSE is executed.

%INCLUDE statements

You can specify an additional script file to be included intothe current script with the %INCLUDE statement.  The format of the %INCLUDEstatement is:

%INCLUDE=StringLiteral

StringLiteral specifies the filename of the script to execute. FileName may include a full path specification.  If a path is not specified,the current Project"s source search path is used to find the include file.  Ifthe file extension is omitted, a default extension of ".SCR" is used.

If an %INCLUDE is encountered during execution of a script, theinclude file is opened and executed.  When execution of the include file iscomplete, script execution continues at the statement immediately following the %INCLUDEstatement.

Example:

IF VersionIs("Debug") THEN

    %INCLUDE="Debug"

ELSE

    %INCLUDE="Normal"

END;

Note: A better and more flexible alternative to %INCLUDE wouldbe to use the CallScript procedure.

Script Parameters

Up to eight parameters may be passed to the script interpreterwhen a script qualifier is specified on the environment command line.  The syntaxof the script qualifier is:

-SCRIPT:ScriptFileName[,Param1[,Param2[,Param3[,Param4]]]]

scriptFileName can be a full file specification including a driveletter, a directory path, a file name, and an extension.  If the drive and pathare omitted, the current defaults are used.  If the extension is omitted, .SCRis used.

Param1, Param2, Param3, Param4, Param5, Param6, Param7 and Param8are optional string literal parameters.

When a script is run from within a Project, the Program parametersoption of the Build menu specify the script parameters.  Do not use the commandline syntax for these parameters.  The parameters are simply separated by spaces. Up to eight script parameters may be specified for scripts run from withinthe environment.

Example:

To specify "S1" and "S2" as script Param1and Param2 respectively:

from CommandLine:

-SCRIPT:MyScriptName,S1,S2

from Program parameters (Build Menu):

S1 S2

In order to use the parameters from within a script, the symbolsPARAM1, PARAM2, ...PARAM8 are used to represent the script parameters.

Built-in Procedures

Built-in procedures are used to create projects, set options,test params and all other functions performed by scripts.  In fact, there arebuilt-in procedures which allow automated control of "all" project options. You will find the procedures and their corresponding built-in types have nameswhich are similar to those used in the environment menus and control panels.  Thebuilt-in procedures are declared as they are in Modula-2 and Ada95.

Some script built-in procedures have BOOLEAN return values.  Parametersare always passed by value (we have no variables in the script language other thanParams).

Parameters fall into 3 general categories:

Built-in (enumerated) types correspond to environment controlpanel pick list or radio button options.  String Literal and numeric range parametersare used where prompt boxes request string or numeric input.

Example of SetCompilerOption built-in declaration:

PROCEDURE SetCompilerOption(cOpt : CompilerOption;

                            scope: OptionScope;

                            setting: OptionSetting);

where:

CompilerOption, OptionScope, and OptionSetting are defined asfollows:

 

TYPE

    CompilerOption = (CheckSubscripts, CheckAssignments,....);

    OptionScope = (GlobalOption, LocalOption);

    OptionSetting = (Yes, No, Global, .....);

and:

cOpt is the compiler option to receive the new setting.

scope designates if the option should be applied globally oronly to the selected module.

setting is the actual option setting.

Example of SetCompilerOption usage:

SetCompilerOption(CheckSubscripts, GlobalOption, Yes);

This enables subscript checking globally in the current project.