.figure 15 .center;DOC - TEMPLATE DOCUMENT GENERATION .blank;.center;AUTHOR: W. KORENDYK .blank;.center;TASK IDENT: 790510 .blank;.center;DOCUMENT VERSIONS .blank;.center;ASDW\MK790511 .center;ASDDJK790706 .center; .center; .center; .center; .center; .center; .center; .center; .blank 6 This document written and supported locally by the staff of the Atmospheric Sciences Division, Alberta Research Council. .comment; Reset initial modes and argument values here. .autoparagraph ;.comment Paragraph if space/tab in column 1. .flags capitalize;.comment Capitalize words beginning with "<". .flags hyphenate ;.comment Unhyphenate words beginning with "=". .period;.comment ; Enable period-2 spaces after period-separator. .right margin 70 .page .center;DOC - TEMPLATE DOCUMENT GENERATION .title;TEMPLATE DOCUMENT GENERATION .subtitle; .skip 2 .center;TABLE OF CONTENTS .skip 3 .nofill .tab stops 10,15,17,23,36 1.0 OVERVIEW .skip 2.0 DOC COMMANDS .blank 1 2.1 @ indirect input file 2.2 COMMENT comment 2.3 DEFINE string definition 2.4 GOTO branching 2.5 IF conditional execution 2.6 LABEL label definition 2.7 MARK mark current output position 2.8 PROMPT terminal output 2.9 QUERY logical input 2.10 SUBSTITUTE string substitution 2.11 TERMINAL terminal input .skip 3.0 STRING CONSTANTS .blank 1 3.1 Predefined Constants 3.2 Input Constant .skip 4.0 ERROR MESSAGES .skip 5.0 EXAMPLES .blank 1 5.1 UICDOC.SRC 5.2 LIBBUG.SRC .page .fill .hl 1 OVERVIEW DOC is a locally written RSX-11M CUSP (Commonly Used System Program) to assist in the generation of documents, using templates to ensure uniform appearance. Like all CUSPs, DOC may be initiated in several ways. The common methods are: .list .le Single DOC command from MCR: .skip .indent 7;&>DOC command__string_ .skip DOC will execute the command__string, and when complete, will return to MCR. .le Multiple DOC commands: .skip .indent 7;&>DOC_ .skip after which an explicit DOC prompt is given: .skip .indent 7;^&DOC>\& .skip This prompt indicates that DOC is ready to accept a command string. DOC will execute the command string and return with another DOC> prompt. .els To leave DOC after using method#2 above, the user must enter an end-of-file instead of a command string following the DOC prompt. This is done by typing a CTRL/Z (depressing the CTRL and Z keys simultaneously). DOC will terminate and return to MCR. .break The DOC command string is of the form: .skip .center;outfile[_=infile] .skip where 'outfile' and 'infile' are valid FILES-11 file specifications, with default values given in Table 1-1. .skip 2 .test page 13 .center;Table 1-1 .center;File Specification Default Values .skip .nofill .tab stops 8,18,21,39,42,65,66 .lm 5 ------------------------------------------------------------- | element | #####infile | #######outfile | |-----------------------------------------------------------| | device | SY0: | SY0: | | [UIC] | ###########[current default UIC] | | filename | DOC | no default | | filetype | SRC | RNO | | version | highest numbered | next-higher numbered | ------------------------------------------------------------- .skip 1 .fill .lm 0 The 'outfile' specifies the file to contain the generated document; the 'infile' specifies the file which is used as a template in generating the document. DOC reads lines from the input file and writes these lines to the output file, with the exception of those lines which begin with the character "$" in the first column. This control character indicates that the line is a##'DOC command record'. .test page 15 .hl 1 DOC COMMANDS Within a DOC command record, the character string following the control character#($), up to the command terminator#(space or tab), is taken to be a## 'DOC command'. The currently accepted DOC commands are given in Table 2-1. .skip 2 .test page 18 .nofill .center;Table 2-1 .center;DOC Commands .skip .lm 10 .ts 13,25,28,58 ------------------------------------------------- | Command | ##########Function | |-----------------------------------------------| | @ | indirect input file | | COMMENT | comment | | DEFINE | string definition | | GOTO | branching | | IF | conditional execution | | LABEL | label definition | | MARK | mark current output position | | PROMPT | terminal output | | QUERY | logical input | | SUBSTITUTE | string substitution | | TERMINAL | terminal input | ------------------------------------------------- .skip 2 .fill .lm 0 Commands may be abbreviated to a single character. For example, the command records: .skip .indent 10;$PROMPT This line of prompt is output to the terminal. .indent 10;$P This line of prompt is output to the terminal. .skip specify the same action to be performed. DOC recognizes both upper- and lower-case commands. An unrecognized command is assumed to be a COMMEMT, and causes the entire record to be ignored. No error or warning message is given. .blank The remainder of this section describes each of the DOC commands. .tp 10 .hl 2 @ - indirect input file The at-sign character (@) indicates that the text which immediately follows is the specification of the file to which DOC is to go for further input records. This indirect file then becomes the##'current input file', and when the processing of that file is complete, DOC resumes processing of the previous input file at the record following the Indirect Input File command record. The @ character may appear in the first position in the record; if the command character is in the first position, it will still be recognized as an Indirect Input File command record. Following are some examples of valid Indirect Input File command records: .skip 1 .indent 10;$@DM2:[111,2]LEVEL2.SRC .indent 10;$@Level3 .indent 10;@NEWINPUT.DAT .skip 1 The defaults for the indirect file specification are the same as for 'infile'. The Indirect Input File command accepts string variable substitutions (see section 2.10). .tp 10 .hl 2 COMMENT - comment Comments allow for the annotation of the input file. The COMMENT command record neither causes any action by DOC nor is it written to the output file. .skip .indent 10;$COMMENT We can comment our input file so that .indent 10;$COMMENT if changes become necessary, it will .indent 10;$C#######be easier to make the modifications. .tp 10 .hl 2 DEFINE - string definition The string variable names must be a single alphanumeric character (A to Z, 0 to 9). Thirty-six string variables may be defined, each able to contain up to thirty-one characters. .skip 1 .center;$DEFINE B character__string .BLANK The character__string can itself contain string variable substitutions#(see section 2.10). Processing of this command record does not cause anything to be output to the output file. .blank A number of string variables are pre-defined by DOC#(see section 2.3), but can be altered with the DEFINE command. .tp 10 .hl 2 GOTO - branching The GOTO command causes the processing of the input file to resume at the record immediately following label__name as defined by a LABEL command: .skip 1 .center;$GOTO label__name .skip 1 The label__name must be a single alphanumeric word less than sixteen characters in length. The remainder of the command record is ignored. .tp 10 .hl 2 IF - conditional execution This command allows for the conditional execution of an input file record, dependent on the value of a logical variable. The syntax for the command record is: .skip 1 .center;$IF variable__name line__to__execute .skip 1 If the value of variable__name #(as defined by a previous Query command) is "true", the line__to__execute is processed as though it were an input record; thus the line__to__execute may itself be a DOC command record. If the value of variable__name is "false", the remainder of the IF command record is ignored. If variable__name is undefined, it defaults to a value of "false". Only the first four characters of variable__name are recognized. .skip 1 .tp 10 .hl 2 LABEL - label definition This command defines a "label" in the input file: .skip 1 .center;$LABEL label__name .skip 1 The label__name must be a single alphanumeric word less than sixteen characters in length. The remainder of the command record is ignored. .tp 15 .hl 2 MARK - mark current position in the output file This command is used in conjunction with the TERMINAL command#(section 2.11). The current position in the output file is retained on an internal stack, and no other action is taken. The maximum number of marked positions retained on the stack is nine. An attempt to exceed this limit causes the 'oldest' marked position to be lost. The remainder of the command record is ignored. .skip .indent 10;$MARK and retain this position in the output file. .tp 10 .hl 2 PROMPT - terminal output With the PROMPT command the part of the command record following the command terminator is output to the user terminal#(TI:), not to the output file. This enables the DOC template file to communicate with the user. .skip .indent 10;$PROMPT You will now be asked for the name and .indent 10;$P######address of the person to whom the letter .indent 10;$P######is to be sent. .skip The PROMPT command accepts string variable substitutions#(see section 2.10). .tp 10 .hl 2 QUERY - logical input The QUERY command allows for the user specification of a logical#(true/false) variable. The command record is of the form: .skip 1 .center;$QUERY variable__name [prompt__string] .blank Only the first four characters of variable__name are recognized. The prompt__string is output to the terminal and a answer is waited for. If no prompt string is specified, the default prompt string "[Y/N]?" is output. The answer given defines the logical value of variable__name. The valid answers are: .skip 1 .nofill .lm +20 Y (or y) _=> Yes (true) _### _=> Yes (true) N (or n) _=> No (false) _#### _=> No (false) .fill .lm 0 .blank An invalid answer causes DOC to reprompt with prompt-string until a valid answer is given. A CTRL/Z response causes processing of the current input file to be terminated. The QUERY command accepts string variable substitutions in the prompt string (see section 2.8, 2.10). .tp 10 .hl 2 SUBSTITUTE - string substitution This command must be used for all strings written to the output file which contain a variable name which requires substitution. String substitution may also be used in some other commands. The string variable may have been defined by the DEFINE command#(section 2.3) or already exist as a pre-defined constant string#(section 3.0). The variable substitution is indicated by a percent sign (%) preceding the single-character variable name. For example, if the variable W contains: .skip 1 .center;WEDNESDAY .skip 1 and the command record is: .skip 1 .center;$SUBSTITUTE Today is %W .skip 1 the following record will be written to the output file: .skip 1 .center;Today is WEDNESDAY .skip 1 It is also possible to specify portions of the string by using the following construct: .skip 1 .center;%A(n,m) .skip 1 where 1 _=_