home *** CD-ROM | disk | FTP | other *** search
- /GOSUB Heading
- This command allows you to setup your »%t«DO»#« script as a
- document. It is especially handy for automated
- documentation. With »ye«DocumentMode»#« set »re«ON»#«, the labels in your
- script act like chapters in a book. The script will process
- as long as you are in the same "chapter" and will terminate
- processing when you reach a new chapter.
-
- Once the "chapter" has been processed, the script returns to
- the special label "»ye«TOC»#«" (for »cy«Table of Contents»#«). The "»ye«TOC»#«"
- section is used to select a new "chapter" to read.
-
- The chapter being processed must be stored in the special
- variable "»ma«CHAPTER»#«". This will be used by the system to
- determine when a section is completed.
-
- Document mode is reset to »re«FALSE»#« each time you »%t«Exec»#« a script
- or enter »ye«Interactive mode»#« ("»%t«/INTERACTIVE»#«"). The status is
- reset when the »%t«Exec»#«'ed script returns ("»%t«/ENDEXEC»#«") or you
- exit Interactive mode ("»%t«/EXIT»#«").
-
- Even though document mode is reset each time you exit a
- script, it is good programming practice, however to set
- document mode »re«OFF»#« when you exit a script.
-
- The following is a simplified »%t«/DOCUMENT»#« script. It
- has been written in two columns so you can see it on the same
- page.
-
- .pg wi full clr
- /DOCUMENT ON │ :1
- :TOC │ {Body of chapter 1}
- Select Chapter: │ :1.1
- │ {Body of section 1}
- 1. Chapter 1 │ :1.2
- 1.1 Section 1 │ {Body of section 2}
- 1.2 Section 2 │ :2
- 2. Chapter 2 │ {Body of chapter 2}
- 2.1 Section 1 │ :2.1
- 2.2 Section 2 │ {Body of section 1}
- 0. Exit │ :2.2
- /SET Def 0 │ {Body of section 2}
- /ASK CHAPTER Def "Chapter:" │ :0
- │ /DOCUMENT OFF
- │ * END of SCRIPT
- ──────────────────────────────────┴─────────────────────────────────────────
- .reset go 1 1
- »bo«/DOCUMENT ON»#« │ :1
- /GOSUB SetWindow
- The »%t«/DOCUMENT»#« command sets the document mode on. Then the script
- drops into the table of contents section.
- .pg wi full go 1 1
- /DOCUMENT ON │ :1
- .go 1 13
- /ASK »bo«CHAPTER»#« Def "Chapter:" │ :0
- /GOSUB SetWindow
- Note the use of the special variable »ye«CHAPTER»#«. This will be
- used by the system to determine when the section is complete.
- .pg clr
- Labels in the sections must take a form that has the »ye«CHAPTER»#«
- followed by sub-chapters: »gr«{chapter}{subchapter}{section}...»#«
-
- »%t«DO»#« will continue to process sections until it finds a label
- which does not fit the pattern in the »ye«CHAPTER»#« variable.
- .pg wi full go 1 1
- /DOCUMENT ON │ »bo«:1»#«
- :TOC │ {Body of chapter 1}
- Select Chapter: │ »bo«:1.1»#«
- │ {Body of section 1}
- 1. Chapter 1 │ »bo«:1.2»#«
- 1.1 Section 1 │ {Body of section 2}
- 1.2 Section 2 │ »+re«:2»#«
- .go 1 13
- /ASK CHAPTER Def "Chapter:" │ :0
- /GOSUB SetWindow
- For example, if you entered "»ye«1»#«" in response to the »%t«/ASK»#« prompt,
- »%t«DO»#« would process sections "»gr«:1»#«","»gr«:1.1»#«","»gr«:1.2»#«", but would stop
- at label "»re«:2»#«" since it does not match the pattern of having "»ye«1»#«"
- at the start of the label.
- .pg wi full
- /DOCUMENT ON │ :1
- :TOC │ {Body of chapter 1}
- Select Chapter: │ :1.1
- │ {Body of section 1}
- 1. Chapter 1 │ :1.2
- 1.1 Section 1 │ {Body of section 2}
- 1.2 Section 2 │ :2
- /GOSUB SetWindow
- .clr
- »gr«NOTE»cy«: »%t«DocumentMode»#« can be turned »ma«OFF»#« in a document section to
- process »%t«DO»#« commands which rely on labels and then turned
- »ma«ON»#« again to continue to process the remainder of the
- script as a document.
- .pg clr
- Now, we'll execute »ye«TESTDOC.SCR»#« which implements this basic script
- so you can see the workings of the »%t«/DOCUMENT»#« command.
-
- /PAGEPROMPT "Press <enter> to start TESTDOC.SCR"
- .pg wi full
- /PAGEPROMPT
- /TESTDOC
- /GOSUB Heading
- As you have seen, »%t«DocumentMode»#« provides important features
- when using »%t«DO»#« to implement on-line documentation.
-
- /GOTO END
- :SetWindow
- .wi 1 17 80 25 clr
- /RETURN
- :Heading
- .pg wi full clr cy
- COMMAND NAME»gray«: »%t« SetDocumentMode »ye«
-
- /DOCUMENT {ON|OFF}
- /cw
- /RETURN
- :END
- /ENDEXEC
-
-
-