• Aucun résultat trouvé

Using Exec Files

Dans le document Guide 2 (Page 158-162)

9.1 Exec F1les

Exec files are scenarios of commands to the Workshop system. They are contained in text fUes, created with the Editor, and are executed wIth the Run command. Exec files consist of characters you type to the Workshop to perform the functions you want, and special exec file commands, which enable you to use parameters and conditions to vary portions of the scenario.

In its simplest form, an exec file contains the characters you press to perform a desired operation. All example of an exec file to compile a Pascal program is:

SEXEC

Pmyprog SEtIlEXEC

{ You

need to

enter

tw blCl1k lines

here }

{ to IUl the COOp11er }

where P is the command to invoke the Pascal Compiler, and myprog is the name of the source file. Further lines to Generate, Link, and Run the

program might follow.

Two separate activities occur while running an exec file: processing and running. First, during process time, the exec processor creates a teInpOr81Y

file, which consists of a stream of Workshop commands. This temporary file is then sent to the Workshop ... which executes the command stream at /lin time.

A simple diagram of this procedure follows:

exec file (s) Workshop

tempf!le /

~.~:.:.:~':': ·Illl:':~

~ ::::::: ..

':

... -

~

· ... ·.'"x .. :.:.·: .. :

~ .

'T'

exec processor

process

time . run

time

With special exec file commands, you can use parameters and conditionally perform the Workshop commands. An example of an exec file for a simple Pascal program is shown in Figure 9-1.

Workshop User's GlIjde Exec FjJes

$EXEC { -makeprog- -- This exec file coopiles, generates, and

lin<s a Pascal program. } P%o

{ no

listing file}

{ default I-code file}

~o

{default object file}

l%O

IOSPASlIB,

{ end of 11nker 11llUt } { no list file }

'Of

output file rae }

$BI)EXEC

figure 9-1 E>aJl)le Exec file

You have several options available to you when running the exec file processor. The Step Mode option; which enables you to selectively skip command lines going to the temp file ... could be used in the above example to choose whether to do only the compile ... generate, or link. Section 9.3.1 contains additional information on the exec file options.

92 Exec File Statements

Exec fHe statements are Une orIented. Two types of exec file lines exist:

e.1(8C COfl7ll18l'll11il1tJs and 1101nK1i Nne.}: Normal lines contain WorkShOp Commands. Exec command Hnes handle the other features of exec files ... SUCh as parameters and .Gondi tional statements.

You can use up to 10 parameters in an exec file, numbered %0 through %9.

parameter

You can pass parameters when you invoke an exec file ·and use them during the execution of the exec flle. For example, if you wanted to pass a parameter In the Example Exec File shown in Figure 9-1, you would Run:

<makeprog (myprog)

WOrkshop User's Guide Exec Files

Exec command lines start with a $ (dollar slgn~ They control the operation of the rest of the exec file. Exec command lines are free format, as· long as the order of their elements is preserved. You can have any number of spaces before or after any element of a command lIne. These can go on to more than one line. The processor will look on the next line if it does not have a complete command at the end of a line.

Normal lines contain commands for the WorkshOp system. These lines are sent to the workshOp as they appear, with the following exceptions:

1. LeadIng and traUlng blanks are removed from these lInes unless the "B"

optlon is in effect. See section 9.3.1 for more on the "B" optlon.

2. Comments are removed.

3. Parameters are expanded.

4. The tilde

C)

literalizing character is proceSSed.

Comments are delimited by brackets { }, and can appear in either a normal or an exec command llne. These can cross llne boundaries. They can be used to comment out carriage returns in normal lines.

The ... is used as a literalizing character in normal lines, meaning it passes the character following it through without processing. With a tUde you can pass the character $, %, or { to the WorkShop system without having it be interpreted as part of an exec command, a parameter, or a comment. To represent a tilde, use a double tilde

C -

~

Note that whHe the exec fHe processor Is not case sensItive, It does preserve the case of parameters and strings supplied by the user.

A description of each exec command follows.

9.2.1 Beglming CI1d EndIng Exec FlIes

Generall y, exec files must begin wi th an EXEC line and must end with an EI'IJEXEC .11ne. The exceptions to this basic rule, for those who embed exec files in their program sources, are: (1) one line of text can preceed the EXEC line if the I (Ignore) invocation option Is used, and (2) any amount of text can follow the EI'DEXEC line, but it is ignored.

9.2.2 Setting Parcmeter values

You can set parameter values in an exec file by using the SET and CEF Al..l... T commands. The REQlJEST command prompts the user for the value of a parameter.

Wolksllop User's Guide Exec Files

9.2.2.1 The SET 8'ld ClEF AU... T COrnrncrlds

The SET and ClEF AlLT . commands provide. ways to Change the value of a parameter inside of an exec file. The forms of these commands are:

set statement

-($

SETH parameter

~tring expreSSion~

and

default statement

$ DEFAULT parameter

string expression

"String expression" Is described in Section 9.2.5.

The SET command changes the value of the specified parameter to the value of the given string expression. The DEF AlL T command Is similar to the SET command, except that the assignment takes place only if the value of the specified parameter is the null string when the OEFAlL T command is

encountered. Thus, you can use this command to supply default values to parameters that have been left unspecified or empty in the exec invocation Une.

These commands also allow you to use unused parameters as variables wlthln the exeo f11e.

9.2.2.2 The REQLEST

ca

III

a

Id

The RFQLEST command provides a way to prompt for values from the console. The form of this command is:

request statement

-C

$ REQUEST}--i parameter

WorkShop User's Guide Exec Files

The REQUEST command prInts the gIven strIng expressIon

to

the console, and

Dans le document Guide 2 (Page 158-162)