• Aucun résultat trouvé

communicating With T50

Dans le document Program Product (Page 147-152)

The .SY [System Command] control word can be used to specify TSO commands and procedures to be executed after SCRIPT/VS completes processing an input file. The commands speci fied wi th . SY are passed to TSO for execution in the order they are encountered, provided SCRIPT/VS was not invoked from a TSO ClIST.

For example, the .SY [System Command] control word might be used to display the output file after i t has been formatted. To request that the document be sent to an output file, you can specify

script infile file('outfile') ...

within the file. This causes the output file to be displayed:

.sy edit 'outfile' old

CHAPTER 12. SYMBOLS IN YOUR DOCUMENT

By using symbols, you can refer to page numbers, variable values, character strings, and control words in your input file. A symbol has a name and a value. When SCRIPT/VS encounters a symbol name, i t replaces i t with the symbol's current value. After all symbol names in an input line have been replaced with their current val-ues, SCRIPT/VS processes the line.

Define a symbol with the .SE [Set Symbol] control word. For exam-ple, to define the symbol &printer, you can issue

.se printer

=

'IBM 1403 Printer'

later, you can refer to the symbol "printern in an input line as

"&printer". Each SCRIPT/VS symbol is identified with its prefix, an ampersand (&). The symbol is terminated with either a period

C.) or a blank. For example, the input line Our publisher uses the &printer for output.

is processed by SCRIPT/VS and printed as:

Our publisher uses the IBM 1403 Printer for output.

but,

Our publisher uses the &printer ..

is processed as:

Our publisher uses the IBM 1403 Printer.

Your document might contain the symbol "&printern many times, in different places. In the future, when you want the document to describe a different printing device, you can reset the symbol with

.se printer = '3800 Printing Subsystem'

At that time, SCRIPT/VS will process your document and substitute the new value for the same symbol:

Our publisher uses the 3800 Printing Subsystem for output.

The symbol's name can be up to ten characters long, and may con-tain upper and lowercase characters, numbers, and the characters

a,

I, and $.

The symbol's value can be a character string, a numeric value, another symbol, or an arithmetic expression. It can contain com-pound data items with imbedded blanks and control words. If the symbol's value contains blanks or special characters, enclose the entire value in single quotation marks Cas shown in the example above).

Some examples of valid symbol definitions are:

.se corp

=

'Scriptographicology, Inc.

,

.se add

=

1

.se incr

=

&add + 1

.se mult

=

&add

*

10

.se test

=

testa

.se TEST

=

testb

You can set a symbol to:

• A numeric value:

.se number

=

25

• A char~cter string:

Chapter 12. Symbols in Your Document 129

.se textl

=

'IBM 1403 Printer'

• A character string that includes a quoted phrase:

.se type 'prepared on a 'word processing' machine

A SCRIPT/VS control word:

.se break

=

'.br'

-. The value of another symbol:

.se printer

=

'&textl'

You can perform integer a ri thmeti c wi th

To increment it:

.se next = &number + 1

To decrement it:

.se prev = &number

-

1

To divide it:

.se half = &number / 2

To multiply it:

.se cost = &number

*

20

To negate a value:

.se negvalue = -&number

symbols:

Symbols can also be set using the . RV (Read Variable] control' word. The .RV control word allows you to enter symbol values from a terminal during SCRIPT/VS processing in interactive environ-ments. For details, see ".RV [Read Variable]" on page 311.

Symbols can be set to a part of the value of another symbol by using the SUBSTR (substring) parameter of the .SE [Set Symbol]

control word. The substring is one or more characters of the char-acter string (the symbol's value). For example,

.su off

.se corp = 'Scriptographicology, Inc.' .se name

=

substr &corp 1 6

.su on

sets the symbol &name to the substring of the value of the symbol

"&corp" beginning with character 1 and continuing for 6 charac-ters. Because "&corp" has been previousl y set to

"Scriptographicology, Inc.", this substring results in the symbol

&name having the value of the 6-character substring "Script".

In the same manner, the SUBSTR (substring) function can be used to extract characters from a character string that is not another symbol's value. For example,

.se name = substr Jonathan 5 4

sets the symbol &name to that 4-character substring of "Jonathan"

beginning with character 5: the symbol &name will have the value

"than". The substring must follow the rules for character string values of a symbol. If the string contains any imbedded blanks or special characters, including arithmetic operators, i t must be enclosed in single quotation marks.

You can use the INDEX function of the .SE [Set Symbol] control word to find the location of a string of characters within a sym-bol value or a string of characters. For example,

.se name

=

'Nicola'

.se location

=

index &name cola

defines the symbol &location to have the value 3, because the string 'cola' starts with the third character of the value of

&name (Nicola).

HOW SCRIPT/VS SUBSTITUTES VALUES FOR SYMBOL NAMES

When SCRIPT/VS processes an input line, i t first scans for any symbols in the line that require substitution. SCRIPT/VS checks any character string that begins with an ampersand (&) to see if i t is a symbol name. When SCRIPT /VS finds a valid symbol, i t replaces the symbol's name with its value. A symbol name is termi-nated either with a blank, a period (.), or the end of the input line. If the symbol name is terminated with a blank, the blank is treated as a normal input character and is left in the input line.

If the symbol name is terminated with a period, the symbol value, after substitution, is concatenated with the next input character and the period is removed. Therefore, i f a symbol has punctuation immediately after it, you must concatenate the punctuation char-acter to the symbol with a symbol-end period. For example,

This list ends with an &iteml ..

results in an end-of-sentence period concatenated with the value of the symbol named &iteml. Otherwise, SCRIPT/VS considers a sin-gle period as the end-of-symbol indicator and concatenates the symbol with the next character.

You should use this technique when the symbol precedes other punc-tuation marks or text. For example,

compound Symbols

The name of our product is &prodname., which is planned for shipment on &shipmo &shipday., 19&shipyr ..

In this example, values for the symbols are substituted with the adjacent text and punctuation wi th no intervening blanks. The printed sentence appears as:

The name of our product is Whizbanger, which is planned for shipment on 12 September 1982.

If you do not place a concatenating period between &prodname and its punctuation (,), SCRIPT/VS regards "&prodname," simply as a character string, and performs no substitution.

You can redefine a symbol as often as necessary in your input file. Each time you redefine the symbol with the .SE [Set Symbol]

control word, the new value replaces the old value.

Symbol substitution is performed before the line is evaluated.

The resul t of symbol substi tution may cause· the original input line to be split into more than one line whether a control word modifier is used or not.

When SCRIPT/VS substitutes values for symbol names, i t performs as many substi tutions as necessary to resolve the symbol name.

Because of this, you can use a compound symbol, composed of two or more separately defined symbols. For example, when you define the symbols

.se x = 1

.se typel

=

first

.se type2

=

second

the input line

This is the &type&x try.

Chapter 12. Symbols in Your Docum~nt 131

results in:

This is the 8typel try. (intermediate result) This is the first try.

Another example of compound symbols is in "Elaborating the System Date" on page 138.

Unresolved Symbols

Sometimes SCRIPT/VS encounters a symbol name that has not yet been defined. In this case, the symbol is unresolved and remains in the input line as a character string that happens to begin with an ampersand. The unresolved symbol is printed on the output page as it appears in the input line.

When you use symbols that are set later in the document than they are referred to (such as a symbol that refers to a page number or a figure number), the symbol will be unresolved when first encountered. When you specify the TWOPASS option with the SCRIPT command, SCRIPT/VS processes the input file twice. As a result, properly defined symbols not resolved during the first formatting pass will be resolved during the second pass.

Inhibiting Substitution

Usually, ampersands that occur in an input file as ordinary text characters are treated as text characters and not as symbol delim-iters. The context in which it appears usually prevents the text ampersand from being mistaken for a symbol name. Where a text ampersand precedes a character string that forms a defined symbol name that you want treated as a text character string, there are several ways to inhibit symbol substitution:

• Turn off substitution with the .SU [Substitute Symbol] con-trol word. With the .SU OFF control word, all substitution is turned off. You can turn symbol substitution on again with .SU

ON.

• Contrive to make the symbol name unrecognizable by adding punctuation without a delimiting period. For example,

I have defined the symbols &AAA, 8BBB, 8CCC, and others for this file.

The symbol for the day of the month (8SYSDAYOFM) is maintained by SCRIPT/VS.

Use the symbol "8xyz" for this purpose.

• Translate an unused punctuation mark or special character on your keyboard to the ampersand, and enter the special charac-ter in your input whenever you need a text ampersand:

.tr ¢

&

Because the translation happens after symbol substi tution, the text ampersand cannot be mistaken for a symbol-starting ampersand.

• Define a symbol to have the value of an unused hexadecimal code and translate that code to an ampersand. Enter the symbol name in your input whenever you need a text ampersand. The 8X' attribute can be used to assign the unused hexadecimal code to a symbol. For example,

.se ·amp = 8x'07 .tr 07 8

defines a symbol named "8amp" whose value is the single hexadecimal code 07, and establishes an output translation which maps that hexadecimal code to the character 8.

You can use the symbol &amp whenever you want an ampersand to appear.41

There are many times when text ampersands are perfectly safe and there is no need to worry about an unexpected substitution. Any time the character string immediately following the ampersand is not a symbol name, no substitution occurs. A character string can-not be a symbol name if:

• It has not been defined as such with a previous .SE [Set Sym-bol] control word

• It contains a character that would not be allowed in a symbol name (before the first blank or period that ends a symbol name)

• It contains more than ten characters before a blank or period

Canceling a Symbol

When you no longer want to use one of the symbols you've previous-ly defined, you can cancel the symbol:

.se oldsymbol off

The symbol &oldsymbol will be regarded by SCRIPT/VS as an unde-fined symbol. It is as though it had never been deunde-fined; it is not regarded as a null-value symbol. When you specify

.se oldsymbol =

-or-.se oldsymbol

= "

you redefine the symbol with a "null" value. It exists as a symbol but it has as its value the null string. Note that a null symbol is quite different from an undefined symbol. The null symbol is substituted with a value: the zero-length null string.

Dans le document Program Product (Page 147-152)