home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / tools / a970.src < prev    next >
Encoding:
Text File  |  1988-05-03  |  93.1 KB  |  3,516 lines

  1. ::::::::::
  2. a970.dis
  3. ::::::::::
  4. --
  5. -- Distribution file for A970
  6. --    This programs the TVI 970 and was written in Ada
  7. --
  8.  
  9. --
  10. -- Documentation
  11. --    Prologue
  12. --    Runoff source, Runoff output, and DEC Help file
  13. --
  14. a970.pro
  15. p970.rno
  16. p970.doc
  17. p970.hlp
  18.  
  19. --
  20. -- Pascal Source
  21. --
  22. p970.pas
  23.  
  24. --
  25. -- Ada Source
  26. --
  27. a970.ada
  28. ::::::::::
  29. a970.pro
  30. ::::::::::
  31.  
  32. -------- SIMTEL20 Ada Software Repository Prologue ------------
  33. --                                                           -*
  34. -- Unit name    : A970 (P970, or PROG970)
  35. -- Version      : 1.7
  36. -- Author       : Freeman Moore
  37. --              : TI Ada Technology Branch
  38. --              : PO Box 801, MS 8006
  39. --              : McKinney, TX  75069
  40. -- DDN Address  : FMOORE%TI-EG at CSNET-RELAY
  41. -- Copyright    : (c) N/A
  42. -- Date created :  26 Apr 85
  43. -- Release date :  26 Apr 85
  44. -- Last update  :  26 Apr 85
  45. -- Machine/System Compiled/Run on :  DG MV 10000 (ROLM ADE)
  46. --                    DEC VAX 11/785 (DEC Ada)
  47. --                                                           -*
  48. ---------------------------------------------------------------
  49. --                                                           -*
  50. -- Keywords     :  TVI970 Terminal, Terminal, Terminal Programming
  51. ----------------:
  52. --
  53. -- Abstract     :  
  54. ----------------:  
  55. -- 
  56. --      PROG970 in Pascal, by Rick Conn
  57. --               converted to Ada by Freeman Moore, April 1985
  58. -- 
  59. --      The purpose of PROG970 is to Program the TVI 970 terminal from
  60. --      a file, setting a variety of its features.  These features include
  61. --      the following:
  62. -- 
  63. --              o User Message Line
  64. --              o Function Keys
  65. --              o Cursor Type
  66. --              o Key Click
  67. --              o 25th Line Display
  68. --              o Answerback Sequence
  69. --              o Programmable Keys
  70. --              o Personal Messages
  71. --              o Other User-Definable Char Sequences
  72. -- 
  73. --                                                           -*
  74. ------------------ Revision history ---------------------------
  75. --                                                           -*
  76. -- DATE         VERSION    AUTHOR                  HISTORY
  77. -- 4/26/85    1.7    Freeman Moore        Initial Release
  78. --                                                           -*
  79. ------------------ Distribution and Copyright -----------------
  80. --                                                           -*
  81. -- This prologue must be included in all copies of this software.
  82. --
  83. -- This software is released to the Ada community.
  84. -- This software is released to the Public Domain (note:
  85. --   software released to the Public Domain is not subject
  86. --   to copyright protection).
  87. -- Restrictions on use or distribution:  NONE
  88. --                                                           -*
  89. ------------------ Disclaimer ---------------------------------
  90. --                                                           -*
  91. -- This software and its documentation are provided "AS IS" and
  92. -- without any expressed or implied warranties whatsoever.
  93. -- No warranties as to performance, merchantability, or fitness
  94. -- for a particular purpose exist.
  95. --
  96. -- Because of the diversity of conditions and hardware under
  97. -- which this software may be used, no warranty of fitness for
  98. -- a particular purpose is offered.  The user is advised to
  99. -- test the software thoroughly before relying on it.  The user
  100. -- must assume the entire risk and liability of using this
  101. -- software.
  102. --
  103. -- In no event shall any person or organization of people be
  104. -- held responsible for any direct, indirect, consequential
  105. -- or inconsequential damages or lost profits.
  106. --                                                           -*
  107. -------------------END-PROLOGUE--------------------------------
  108. ::::::::::
  109. p970.rno
  110. ::::::::::
  111. .headers on
  112. .title _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ P970 - A Utility for Programming the TVI 970 
  113. .RIGHT MARGIN +15
  114. .LEFT MARGIN +15
  115. .ap
  116. .tab stops 5,10,15,20,25,30,35,40,45,50,55,60
  117. .skip 5
  118. .CENTER +15;  P970 Version 1.6
  119. .skip 1
  120. .CENTER +15;  A Utility for Programming the TVI 970
  121. .skip 1
  122. .CENTER +15;  by Richard Conn
  123. .skip 3
  124.     The purpose of P970 is to program the user's TVI 970 computer
  125. terminal based on commands in a text file.  The following operations
  126. on the TVI 970 can be performed by this program:
  127. .skip 1
  128. .nf
  129.         1. Define the content of the
  130.             User Message on the 25th line
  131.         2. Select the 25th line
  132.         3. Engage/Disengage Key Click
  133.         4. Program the 16 Function Keys
  134.         5. Select the Cursor Type
  135.         6. Program the Answerback Sequence
  136.         7. Program the Programmable Keys
  137.         8. Output any text to the terminal
  138. .fill
  139. .skip 3
  140. .CENTER +15;  ^& Running the P970 Program \&
  141.     P970 performs its function by reading a text file (which may be
  142. created with any VAX/VMS editor) and sending command sequences to the user's
  143. TVI 970 based on P970 commands in the text file.
  144.     A symbol should be defined (via your LOGIN.COM file) which
  145. looks something like this:
  146. .skip 1
  147. .CENTER +15;  P970:=="$USER1:[ACSL.TOOLS.P970]P970 "
  148. .skip 1
  149. As per the norm, you may define the symbol name ('P970') as you desire.
  150. Note the leading dollar sign (_$) -- it is an important part of this symbol
  151. and must not be omitted.  It is sometimes useful to keep all of your P970
  152. command files in one directory, and, consequently, it is convenient to have
  153. a command which runs P970 on files which come from this directory by
  154. default.  My default directory is [CONN.P970], and I store all of my P970
  155. files here.  A symbol, H970 (for Home 970), is defined as follows:
  156. .skip 1
  157. .CENTER +15;  H970:=="$USER1:[ACSL.TOOLS.P970]P970 [CONN.P970]"
  158. .skip 1
  159. The command
  160. .skip 1
  161. .CENTER +15;  "H970 LOGIN.970"
  162. .skip 1
  163. is expanded into
  164. .skip 1
  165. .CENTER +15;  "$USER1:[ACSL.TOOLS.P970]P970 [CONN.P970]LOGIN.970"
  166. .skip 1
  167.     Once the symbol is defined, the program is invoked in one of
  168. two ways:
  169. .skip 1
  170. .nf
  171.     P970        <-- run program; user is prompted for file
  172.     P970 file    <-- run program on specified file
  173.     (same for H970)
  174. .fill
  175. .skip 3
  176. .CENTER +15;  ^& File Structure \&
  177.     The file read by P970 is simply an ASCII text file (which can
  178. be prepared by any conventional text editor under VAX/VMS).  Each line
  179. of the file begins with a command letter ('A', 'C', 'E',
  180. 'F', 'K', 'L', 'O', 'P', 'U',
  181. or ';') followed by command-specific information.  When a line is
  182. encountered which does not begin with one of these characters, processing
  183. is halted (end of command set is assumed).
  184. For all commands, the case of the command letter and any options
  185. which follow it are not significant.  Case is only significant
  186. in the text fields of selected commands.
  187. .skip 3
  188. .CENTER +15;  ^& Potential User Problems \&
  189. .skip 1
  190. 1. VAX/VMS Automatic Line Wrapping
  191.     Your VAX/VMS environment should be set up with NOWRAP as a terminal
  192. characteristic if your output strings are very long.  P970 uses two techniques,
  193. depending on the command used, to generate output to the terminal.  One
  194. technique simply outputs the characters as presented in the P970 command
  195. file.  The other technique involves translating each
  196. character into a sequence of ASCII-code digits and outputting up to three
  197. digits
  198. followed by a semicolon for each character.  Consequently, the output using
  199. this second technique, as is found in the User Message command and others,
  200. can become quite long, and if WRAP is set
  201. on your terminal characteristics, the message will be cut short when the
  202. number of characters output equals the number of columns on your terminal.
  203.     To enable NOWRAP on your terminal, have your LOGIN.COM file
  204. issue the following command:
  205. .skip 1
  206. .CENTER +15;  _"SET TERMINAL/NOWRAP_"
  207. .skip 2
  208. 2. Output Buffer Size
  209.     The next limitation you may
  210. encounter is the size of the output buffer used by P970.
  211. A maximum of 4096 characters is permitted in an output stream
  212. before the buffer will overflow and a message to this effect will appear
  213. on your screen.  Many successive uses of the O (literal output)
  214. command could cause this overflow to happen.  This problem can be corrected by
  215. interjecting a command like:
  216. .skip 1
  217.         O_^M_^J
  218. .skip 1
  219. in your command file.  _^M is a carriage return, _^J is a line feed, and
  220. the two combine to generate the New Line code which flushes the buffer
  221. (actually, _^J is probably the only character needed, but _^M _^J looks
  222. better on your terminal).
  223. .skip 3
  224. .CENTER +15;  ^& Comments \&
  225.     Any line in the file beginning with a semicolon (_;) is a comment
  226. line, and the entire line is ignored.
  227. .skip 3
  228. .CENTER +15;  ^& Text Output Convention \&
  229.     Functions 1 (define User Message), 4 (program function keys),
  230. 6 (program answerback message), 7 (program programmable keys),
  231. and 8 (output text to terminal)
  232. permit the user to output text to the terminal.  P970 provides for some
  233. convenience to the user in that escape sequences are available which allow
  234. any character within the 128-character ASCII character set to be included
  235. in this text.  This is particularly useful when the function keys are being
  236. programmed with escape sequences, such as clear screen.
  237. .test page 10
  238.     The escape sequences available to the P970 programmer are:
  239. .skip 1
  240. .nf
  241.         _^c - output control char (uparrow, char)
  242.         _\D - output DELETE char (7F Hex)
  243.         _\E - output ESCAPE char (1B Hex)
  244.         _\c - output following char literally
  245.             '_\_^' outputs '_^'
  246.             '_\_\' outputs '_\'
  247. .fill
  248. .skip 1
  249.     For example, to include a carriage return character in
  250. a text sequence, the two-character combination '_^M' or '_^m' is available.
  251. To output the clear screen sequence to the TVI 970, the characters
  252. '_\E[2J' will output ESCAPE, '[', '2', and 'J' to do this.
  253.     Any character following an uparrow (_^) or backslash (_\) will
  254. be capitalized if it is lower-case alphabetic.
  255.     Any 7-bit value in the ASCII-128 character set can be generated
  256. by using this output convention.  The following table summarizes how to
  257. do this.
  258. .skip 1
  259. .test page 22
  260. .nf
  261.         Character    Required
  262.          Desired    Character
  263.         Hex ASCII    Sequence
  264.         ---------    --------
  265.         00   NUL       _^@
  266.         01   SOH       _^A
  267.            ...         ..
  268.         1A   SUB       _^Z
  269.         1B   ESC       _^[  (note: _\E also works)
  270.         1C   FS        _^_\
  271.         1D   GS        _^]
  272.         1E   RS        _^_^
  273.         1F   US        _^__
  274.         20   SP 
  275.         21   _!         _!
  276.            ...         ..
  277.         7E   _~         _~
  278.         7F   DEL       _\D  (note: special sequence)
  279. .fill
  280. .skip 1
  281.     Note that a delete character (_\D) is useful in programming
  282. the function keys in that this character is used in function key
  283. sequences to chain one function key to another.
  284. .skip 3
  285. .test page 15
  286. .CENTER +15;  ^& P970 Commands \&
  287. .skip 2
  288.     This section lists the nine P970 commands in alphabetical order.
  289. The commands covered in this section are:
  290. .skip 1
  291. .tab stops 8,16,24,32,40,48,56
  292. .NO FILL
  293.     Command        Function Performed
  294.     -------        -------- ---------
  295.     A<text>        Program the Answerback Sequence
  296.     Ccr            Select the Cursor Type
  297.     E<text>        End Command Lines
  298.     Fst n <text>    Program a Function Key
  299.     Kk             Engage/Disengage Key Click
  300.     Ll             Select the 25th Line
  301.     O<text>        Output any Text to the Terminal
  302.     P n <text>    Program the Programmable Keys
  303.     U<text>        Load the User Message
  304. .fill
  305. .tab stops 5,10,15,20,25,30,35,40,45,50,55,60
  306. .skip 2
  307. .test page 10
  308. 1. ^& A - Program the Answerback Sequence \&
  309. .skip 1
  310. Syntax:
  311.     A<text>
  312. .skip 1
  313. Comments:
  314.     The answerback sequence is transmitted to the computer by
  315. striking Control-BREAK.  This sequence is at most 24 characters long,
  316. and it is the user's responsibility to insure that he does not place more
  317. than 24 characters in this sequence.
  318. .skip 1
  319. Examples:
  320. .NO FILL 
  321.     Ac McACSL_^M_^M
  322.         -- program the answerback key with a
  323.             connect command to McACSL
  324. .fill
  325. .skip 2
  326. .test page 10
  327. 2. ^& C - Select the Cursor Type \&
  328. .skip 1
  329. Syntax:
  330. .nf
  331.     Ccr
  332.         c = 'B' for block (defaults to underline)
  333.         r = 'S' for steady (defaults to blinking)
  334. .fill
  335. .skip 1
  336. Comments:
  337.     The C command selects the cursor type.  If both the 'S' and
  338. 'B' options are selected, their order is not significant.
  339. .skip 1
  340. Examples:
  341. .nf
  342.     C    <-- select blinking underline
  343.     CS    <-- select steady underline
  344.     CB    <-- select blinking block
  345.     CBS    <-- select steady block
  346. .fill
  347. .skip 2
  348. .test page 10
  349. 3. ^& E - Exit P970 Command Series \&
  350. .skip 1
  351. Syntax:
  352.     E<any text>
  353. .skip 1
  354. Comments:
  355.     The E command signals the end of the P970 command lines in
  356. the file.  Any subsequent lines following the line beginning with
  357. the letter 'E' are ignored.  Any text following the E command is
  358. ignored.
  359. .skip 1
  360. Examples:
  361.     E     <-- End of Command Lines
  362. .skip 2
  363. .test page 15
  364. 4. ^& F - Program the 16 Function Keys \&
  365. .skip 1
  366. Syntax:
  367. .nf
  368.     Fst n <text>
  369.         s = 'S' if function key is to be shifted;
  370.             omitting the character 'S' selects the
  371.             non-shifted function key
  372.         t = 'L' if text is transmitted to terminal only;
  373.             omitting the character 'L' selects
  374.             transmission of the text to the computer
  375.         n = number of function key (1 to 16)
  376.         <text> = text of function key
  377. .fill
  378. .skip 1
  379. Comments:
  380.     The function key definition command allows the programmer to
  381. define text strings to be sent to the remote computer or executed locally
  382. by the terminal.
  383.     In sending text strings to the remote computer, it is frequently
  384. useful to terminate the text strings in certain ways, namely with a carriage
  385. return or a space.  To do this, the escape sequences come in handy.  The
  386. characters '_^M' or '_^m' represent the carriage return, and '_\_ ' represents
  387. a space.
  388.     In sending commands to the terminal, it is frequently useful to
  389. be able to define the ESCAPE character.  The sequence '_\E' represents the
  390. ESCAPE character.  Also, the sequence '_\D' represents the DELETE character
  391. (if you ever need it).
  392.     See the section on ^& Text Output Convention \& for more detail.
  393.     If both 'S' and 'L' options are given, the order in which they
  394. are presented is not significant.
  395. .skip 1
  396. .test page 10
  397. Examples:
  398. .nf
  399.     F 1 dir_^M    <-- function key 1 (unshifted) sends
  400.                 'dir' followed by a carriage
  401.                 return to the computer
  402.     Fs 1 dir_\    <-- function key 1 (shifted) sends
  403.                 'dir' followed by a space
  404.                 to the computer
  405.     FL 2 _\E[2J    <-- function key 2 sends ESCAPE
  406.                 followed by '[2J' to the
  407.                 terminal
  408. .fill
  409. .skip 2
  410. .test page 10
  411. 5. ^& K - Engage/Disengage Key Click \&
  412. .skip 1
  413. Syntax:
  414. .nf
  415.     Kk
  416.         k = 'Y' to enable key click
  417.         k = anything else to disable key click
  418. .fill
  419. .skip 1
  420. Comments:
  421.     The key click is enabled or disabled by this command.
  422. .skip 1
  423. Examples:
  424. .nf
  425.     K    <-- disable key click
  426.     Ky    <-- enable key click
  427. .fill
  428. .skip 2
  429. .test page 10
  430. 6. ^& L - Select the 25th Line \&
  431. .skip 1
  432. Syntax:
  433. .nf
  434.     Ll
  435.         l = 'U' selects the User Message
  436.         l = 'S' selects the Status Message
  437.         l = anything else blanks out the 25th line
  438. .fill
  439. .skip 1
  440. Comments:
  441.     The L command selects the 25th line.  Since it is executed
  442. as soon as it is encountered, the L command may also be used to blank
  443. out the message line, load it, and then enable it when the processing
  444. is done.
  445. .skip 1
  446. .test page 10
  447. Examples:
  448. .skip 1
  449. .nf
  450.     1.  Sequence --
  451.         L        <-- blank out 25th line
  452.         Umy message    <-- store 'my message' in User Msg
  453.         LU        <-- enable User Msg on 25th line
  454.     2.  Sequence --
  455.         LS        <-- enable status msg on 25th line
  456. .fill
  457. .skip 2
  458. .test page 10
  459. 7. ^& O - Output any Text to the Terminal \&
  460. .skip 1
  461. Syntax:
  462.     O<text>
  463. .skip 1
  464. Comments:
  465.     The O command simply outputs the following text to the
  466. user's terminal.  Any escape sequence
  467. not covered by the other commands can be sent to the terminal rather easily.
  468. .skip 1
  469. Examples:
  470. .nf
  471.     O_\E[2J    <-- clear screen
  472.     OHello, world    <-- print message
  473. .fill
  474. .skip 2
  475. .test page 10
  476. 8. ^& P - Program the Programmable Keys \&
  477. .skip 1
  478. Syntax:
  479.     P n <text>
  480. .skip 1
  481. Comments:
  482.     The P command programs the programmable key indicated with
  483. the indicated character sequence.  It is the user's responsibility to
  484. ensure that the character sequence fits within the key's buffer.
  485. Any escape sequence
  486. not covered by the other commands can be sent to the terminal rather easily.
  487.     The value of "n" is the PS number of the key (from 0 to 62).
  488. Refer to pages 99-100 of the TVI 970 Operator's Manual
  489. (Programming the Programmable Keys) for details on these
  490. values.
  491. .skip 1
  492. .test page 5
  493. Examples:
  494. .skip 1
  495. .nf
  496.     P 24 _^B     <-- change left arrow to _^B
  497.     P 19 _\EV    <-- change shifted up arrow to ESC V
  498. .fill
  499. .skip 2
  500. .test page 10
  501. 9. ^& U - Set the User Message on the 25th Line \&
  502. .skip 1
  503. Syntax:
  504.     U<text>
  505. .skip 1
  506. Comments:
  507.     The text immediately following the letter U is output into the user
  508. message.  The L command must also select the User Message for this output
  509. to appear on the screen (see the L command below).
  510.     Your VAX/VMS environment should be set up with NOWRAP as a terminal
  511. characteristic if your User Message is very long.  P970 uses the "normal"
  512. technique of generating the User Message, which involves translating each
  513. character into a sequence of ASCII digits and outputting up to three digits
  514. followed by a semicolon for each character.  Consequently, the output to
  515. program a User Message tends to become quite long, and if WRAP is set
  516. on your terminal characteristics, the message will be cut short when the
  517. number of characters output equals the number of columns on your terminal.
  518. However, even with NOWRAP enabled, the next limitation is the size of the
  519. output buffer.  This limitation allows on the order of 40 characters
  520. maximum in the User Message.
  521.     To enable NOWRAP on your terminal, have your LOGIN.COM file
  522. issue the following command:  _"SET TERMINAL/NOWRAP_"
  523. .skip 1
  524. Examples:
  525. .nf
  526.     Umy message    <-- store 'my message' in user line
  527. .fill
  528. .page
  529. .skip 4
  530. .CENTER +15;  ^& Sample Configuration Files \&
  531. .skip 3
  532. FILE 1:
  533. .skip 2
  534. .test page 22
  535. .nf
  536.     ; User line blank, keyclick off, define user message,
  537.     ;   set 25th line to user message
  538.     L
  539.     K
  540.     uD  Dir  ChDir  Who
  541.     Lu
  542.     ; Define function keys
  543.     F 1 d_^M
  544.     Fs 1 d_\ 
  545.     F 2 dir_^M
  546.     F 3 cd_\ 
  547.     F 4 who_^M
  548.     fL 16 _\E[0U
  549.     fsL 16 _\E[0V
  550.     ; Define cursor
  551.     C
  552.     ; Print message
  553.     O_\E[2J Welcome, Rick
  554.     ; Done
  555.     E
  556. .fill
  557. .skip 3
  558. .test page 22
  559. FILE 2:
  560. .skip 2
  561. .nf
  562.     ; Define user message line
  563.     U1=Dir  2=CD  3=Who
  564.     ; Define function keys
  565.     Fn 1 d_^m
  566.     fs 1 d_\ 
  567.     fn 2 cd_\ 
  568.     fs 2 pwd_^M
  569.     fn 3 who_^m
  570.     ; Define cursor
  571.     cb
  572.     ; Done
  573.     e
  574.     These lines which follow the E command may
  575.     contain any text desired by the user
  576. .fill
  577. .skip 3
  578. .test page 30
  579. FILE 3:
  580. .skip 2
  581. .nf
  582.     ; TVI 970 configuration file for Rick Conn
  583.     ; Set the Answerback message:
  584.     Ac mcacsl_^M_^M
  585.     ; Program the user message:
  586.     L
  587.     u1=D  2=Dir  3=CD  4=Who
  588.     Lu
  589.     ; Turn off key click
  590.     K
  591.     ; Define Function Keys
  592.     ;  1 = d<CR>
  593.     ;  1 shifted = d<SP>
  594.     ;  2 = dir<CR>
  595.     ;  3 = cd<SP>
  596.     ;  4 = who<CR>
  597.     ; 15 = smooth scroll
  598.     ; 15 shifted = jump scroll
  599.     ; 16 = advance to next page
  600.     ; 16 shifted = backup to last page
  601.     F 1 d_^M
  602.     Fs 1 d_\ 
  603.     F 2 dir_^M
  604.     F 3 cd_\ 
  605.     F 4 who_^M
  606.     FL 15 _\E[_?4h
  607.     FLS 15 _\E[_?4l
  608.     fL 16 _\E[0U
  609.     fsL 16 _\E[0V
  610.     ; Set Cursor to Blinking Underline
  611.     C
  612.     ; Clear Screen and Print Message
  613.     O_\E[2J Welcome, Rick
  614.     ; Done
  615.     E
  616. .fill
  617. ::::::::::
  618. p970.doc
  619. ::::::::::
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.                                      P970 Version 1.6
  627.  
  628.  
  629.  
  630.                           A Utility for Programming the TVI 970
  631.  
  632.  
  633.  
  634.                                      by Richard Conn
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.                     The purpose of P970 is to program the  user's  TVI  970
  645.  
  646.                computer  terminal  based  on  commands in a text file.  The
  647.  
  648.                following operations on the TVI 970 can be performed by this
  649.  
  650.                program:
  651.  
  652.  
  653.  
  654.                          1. Define the content of the
  655.  
  656.                               User Message on the 25th line
  657.  
  658.                          2. Select the 25th line
  659.  
  660.                          3. Engage/Disengage Key Click
  661.  
  662.                          4. Program the 16 Function Keys
  663.  
  664.                          5. Select the Cursor Type
  665.  
  666.                          6. Program the Answerback Sequence
  667.  
  668.                          7. Program the Programmable Keys
  669.  
  670.                          8. Output any text to the terminal
  671.  
  672.  
  673.  
  674.  
  675.  
  676.  
  677.  
  678.                                  Running the P970 Program
  679.                                  _______ ___ ____ _______
  680.  
  681.  
  682.  
  683.                     P970 performs its  function  by  reading  a  text  file
  684.  
  685.                (which  may  be created with any VAX/VMS editor) and sending
  686.  
  687.                command sequences to  the  user's  TVI  970  based  on  P970
  688.  
  689.                commands in the text file.
  690.  
  691.  
  692.  
  693.                     A symbol should be defined (via  your  LOGIN.COM  file)
  694.  
  695.                which looks something like this:
  696.  
  697.  
  698.  
  699.                           P970:=="$USER1:[ACSL.TOOLS.P970]P970 "
  700.  
  701.  
  702.  
  703.                As per the norm, you may define the symbol name ('P970')  as
  704.  
  705.                you  desire.   Note  the leading dollar sign ($) -- it is an
  706.  
  707.                important part of this symbol and must not be  omitted.   It
  708.  
  709.                is  sometimes  useful to keep all of your P970 command files
  710.  
  711.                in one directory, and, consequently,  it  is  convenient  to
  712.  
  713.                have a command which runs P970 on files which come from this
  714.  
  715.                directory by default.  My default directory is  [CONN.P970],
  716.  
  717.                and  I store all of my P970 files here.  A symbol, H970 (for
  718.  
  719.                Home 970), is defined as follows:
  720.  
  721.  
  722.  
  723.                     H970:=="$USER1:[ACSL.TOOLS.P970]P970 [CONN.P970]"
  724.  
  725.  
  726.  
  727.                The command
  728.  
  729.  
  730.  
  731.                                      "H970 LOGIN.970"
  732.  
  733.  
  734.  
  735.                is expanded into
  736.  
  737.                P970 - A Utility for Programming the TVI 970          Page 2
  738.  
  739.  
  740.  
  741.  
  742.  
  743.                    "$USER1:[ACSL.TOOLS.P970]P970 [CONN.P970]LOGIN.970"
  744.  
  745.  
  746.  
  747.  
  748.  
  749.                     Once the symbol is defined, the program is  invoked  in
  750.  
  751.                one of two ways:
  752.  
  753.  
  754.  
  755.                     P970      <-- run program; user is prompted for file
  756.  
  757.                     P970 file <-- run program on specified file
  758.  
  759.                     (same for H970)
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.                                       File Structure
  768.                                       ____ _________
  769.  
  770.  
  771.  
  772.                     The file read by P970 is  simply  an  ASCII  text  file
  773.  
  774.                (which can be prepared by any conventional text editor under
  775.  
  776.                VAX/VMS).  Each line of  the  file  begins  with  a  command
  777.  
  778.                letter ('A', 'C', 'E', 'F', 'K', 'L', 'O', 'P', 'U', or ';')
  779.  
  780.                followed by command-specific information.  When  a  line  is
  781.  
  782.                encountered   which   does  not  begin  with  one  of  these
  783.  
  784.                characters, processing is halted  (end  of  command  set  is
  785.  
  786.                assumed).   For all commands, the case of the command letter
  787.  
  788.                and any options which follow it are not  significant.   Case
  789.  
  790.                is only significant in the text fields of selected commands.
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.                                   Potential User Problems
  799.                                   _________ ____ ________
  800.  
  801.  
  802.  
  803.                1.  VAX/VMS Automatic Line Wrapping
  804.  
  805.  
  806.  
  807.                     Your VAX/VMS environment should be set up  with  NOWRAP
  808.  
  809.                as a terminal characteristic if your output strings are very
  810.  
  811.                long.  P970 uses two techniques, depending  on  the  command
  812.  
  813.                used,  to  generate  output  to the terminal.  One technique
  814.  
  815.                simply outputs the  characters  as  presented  in  the  P970
  816.  
  817.                command file.  The other technique involves translating each
  818.  
  819.                character  into  a  sequence  of   ASCII-code   digits   and
  820.  
  821.                outputting  up  to  three digits followed by a semicolon for
  822.  
  823.                each character.  Consequently, the output using this  second
  824.  
  825.                technique,  as  is  found  in  the  User Message command and
  826.  
  827.                others, can become quite long, and if WRAP is  set  on  your
  828.  
  829.                terminal characteristics, the message will be cut short when
  830.  
  831.                the number of characters output equals the number of columns
  832.  
  833.                on your terminal.
  834.  
  835.  
  836.  
  837.                     To enable NOWRAP on your terminal, have your  LOGIN.COM
  838.  
  839.                file issue the following command:
  840.  
  841.  
  842.  
  843.                                   "SET TERMINAL/NOWRAP"
  844.  
  845.  
  846.  
  847.  
  848.  
  849.                2.  Output Buffer Size
  850.  
  851.                P970 - A Utility for Programming the TVI 970          Page 3
  852.  
  853.  
  854.  
  855.  
  856.  
  857.                     The next limitation you may encounter is  the  size  of
  858.  
  859.                the   output  buffer  used  by  P970.   A  maximum  of  4096
  860.  
  861.                characters is permitted  in  an  output  stream  before  the
  862.  
  863.                buffer  will  overflow  and  a  message  to this effect will
  864.  
  865.                appear on your  screen.   Many  successive  uses  of  the  O
  866.  
  867.                (literal  output)  command  could  cause  this  overflow  to
  868.  
  869.                happen.  This problem can be  corrected  by  interjecting  a
  870.  
  871.                command like:
  872.  
  873.  
  874.  
  875.  
  876.  
  877.                     O^M^J
  878.  
  879.  
  880.  
  881.                in your command file.  ^M is a carriage return, ^J is a line
  882.  
  883.                feed,  and  the  two  combine  to generate the New Line code
  884.  
  885.                which flushes the buffer (actually, ^J is probably the  only
  886.  
  887.                character needed, but ^M ^J looks better on your terminal).
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.                                          Comments
  896.                                          ________
  897.  
  898.  
  899.  
  900.                     Any line in the file beginning with a semicolon (;)  is
  901.  
  902.                a comment line, and the entire line is ignored.
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.                                   Text Output Convention
  911.                                   ____ ______ __________
  912.  
  913.  
  914.  
  915.                     Functions 1 (define User Message), 4 (program  function
  916.  
  917.                keys),   6   (program   answerback   message),   7  (program
  918.  
  919.                programmable keys), and 8 (output text to  terminal)  permit
  920.  
  921.                the  user to output text to the terminal.  P970 provides for
  922.  
  923.                some convenience to the user in that  escape  sequences  are
  924.  
  925.                available which allow any character within the 128-character
  926.  
  927.                ASCII character set to be included in this  text.   This  is
  928.  
  929.                particularly   useful  when  the  function  keys  are  being
  930.  
  931.                programmed with escape sequences, such as clear screen.
  932.  
  933.  
  934.  
  935.                     The escape sequences available to the  P970  programmer
  936.  
  937.                are:
  938.  
  939.  
  940.  
  941.                          ^c - output control char (uparrow, char)
  942.  
  943.                          \D - output DELETE char (7F Hex)
  944.  
  945.                          \E - output ESCAPE char (1B Hex)
  946.  
  947.                          \c - output following char literally
  948.  
  949.                               '\^' outputs '^'
  950.  
  951.                               '\\' outputs '\'
  952.  
  953.  
  954.  
  955.  
  956.  
  957.                     For example, to include a carriage return character  in
  958.  
  959.                a  text sequence, the two-character combination '^M' or '^m'
  960.  
  961.                is available.  To output the clear screen  sequence  to  the
  962.  
  963.                TVI  970,  the  characters  '\E[2J' will output ESCAPE, '[',
  964.  
  965.                '2', and 'J' to do this.
  966.  
  967.                P970 - A Utility for Programming the TVI 970          Page 4
  968.  
  969.  
  970.  
  971.  
  972.  
  973.                     Any character following an uparrow (^) or backslash (\)
  974.  
  975.                will be capitalized if it is lower-case alphabetic.
  976.  
  977.  
  978.  
  979.                     Any 7-bit value in the ASCII-128 character set  can  be
  980.  
  981.                generated  by  using  this output convention.  The following
  982.  
  983.                table summarizes how to do this.
  984.  
  985.  
  986.  
  987.                          Character Required
  988.  
  989.                           Desired  Character
  990.  
  991.                          Hex ASCII Sequence
  992.  
  993.                          --------- --------
  994.  
  995.                          00   NUL     ^@
  996.  
  997.                          01   SOH     ^A
  998.  
  999.                             ...       ..
  1000.  
  1001.                          1A   SUB     ^Z
  1002.  
  1003.                          1B   ESC     ^[  (note: \E also works)
  1004.  
  1005.                          1C   FS      ^\
  1006.  
  1007.                          1D   GS      ^]
  1008.  
  1009.                          1E   RS      ^^
  1010.  
  1011.                          1F   US      ^_
  1012.  
  1013.                          20   SP 
  1014.  
  1015.                          21   !        !
  1016.  
  1017.                             ...       ..
  1018.  
  1019.                          7E   ~        ~
  1020.  
  1021.                          7F   DEL     \D  (note: special sequence)
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.                     Note  that  a  delete  character  (\D)  is  useful   in
  1028.  
  1029.                programming the function keys in that this character is used
  1030.  
  1031.                in function key sequences  to  chain  one  function  key  to
  1032.  
  1033.                another.
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.                                        P970 Commands
  1042.                                        ____ ________
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.                     This  section  lists  the   nine   P970   commands   in
  1051.  
  1052.                alphabetical  order.   The  commands covered in this section
  1053.  
  1054.                are:
  1055.  
  1056.  
  1057.  
  1058.                 Command         Function Performed
  1059.  
  1060.                 -------         -------- ---------
  1061.  
  1062.                 A<text>         Program the Answerback Sequence
  1063.  
  1064.                 Ccr             Select the Cursor Type
  1065.  
  1066.                 E<text>         End Command Lines
  1067.  
  1068.                 Fst n <text>    Program a Function Key
  1069.  
  1070.                 Kk              Engage/Disengage Key Click
  1071.  
  1072.                 Ll              Select the 25th Line
  1073.  
  1074.                 O<text>         Output any Text to the Terminal
  1075.  
  1076.                 P n <text>      Program the Programmable Keys
  1077.  
  1078.                 U<text>         Load the User Message
  1079.  
  1080.                P970 - A Utility for Programming the TVI 970          Page 5
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.                1.  A - Program the Answerback Sequence
  1087.                    _ _ _______ ___ __________ ________
  1088.  
  1089.  
  1090.  
  1091.                Syntax:
  1092.  
  1093.  
  1094.  
  1095.                     A<text>
  1096.  
  1097.  
  1098.  
  1099.                Comments:
  1100.  
  1101.  
  1102.  
  1103.                     The answerback sequence is transmitted to the  computer
  1104.  
  1105.                by  striking  Control-BREAK.   This  sequence  is at most 24
  1106.  
  1107.                characters long, and it  is  the  user's  responsibility  to
  1108.  
  1109.                insure  that  he  does  not place more than 24 characters in
  1110.  
  1111.                this sequence.
  1112.  
  1113.  
  1114.  
  1115.                Examples:
  1116.  
  1117.                     Ac McACSL^M^M
  1118.  
  1119.                          -- program the answerback key with a
  1120.  
  1121.                               connect command to McACSL
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.                2.  C - Select the Cursor Type
  1128.                    _ _ ______ ___ ______ ____
  1129.  
  1130.  
  1131.  
  1132.                Syntax:
  1133.  
  1134.                     Ccr
  1135.  
  1136.                          c = 'B' for block (defaults to underline)
  1137.  
  1138.                          r = 'S' for steady (defaults to blinking)
  1139.  
  1140.  
  1141.  
  1142.                Comments:
  1143.  
  1144.  
  1145.  
  1146.                     The C command selects the cursor type.  If both the 'S'
  1147.  
  1148.                and   'B'   options   are   selected,  their  order  is  not
  1149.  
  1150.                significant.
  1151.  
  1152.  
  1153.  
  1154.                Examples:
  1155.  
  1156.                     C    <-- select blinking underline
  1157.  
  1158.                     CS   <-- select steady underline
  1159.  
  1160.                     CB   <-- select blinking block
  1161.  
  1162.                     CBS  <-- select steady block
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.                3.  E - Exit P970 Command Series
  1169.                    _ _ ____ ____ _______ ______
  1170.  
  1171.  
  1172.  
  1173.                Syntax:
  1174.  
  1175.  
  1176.  
  1177.                     E<any text>
  1178.  
  1179.  
  1180.  
  1181.                Comments:
  1182.  
  1183.  
  1184.  
  1185.                     The E command signals the end of the P970 command lines
  1186.  
  1187.                in  the  file.   Any  subsequent  lines  following  the line
  1188.  
  1189.                beginning  with  the  letter  'E'  are  ignored.   Any  text
  1190.  
  1191.                following the E command is ignored.
  1192.  
  1193.  
  1194.  
  1195.                Examples:
  1196.  
  1197.                P970 - A Utility for Programming the TVI 970          Page 6
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203.                     E    <-- End of Command Lines
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209.                4.  F - Program the 16 Function Keys
  1210.                    _ _ _______ ___ __ ________ ____
  1211.  
  1212.  
  1213.  
  1214.                Syntax:
  1215.  
  1216.                     Fst n <text>
  1217.  
  1218.                          s = 'S' if function key is to be shifted;
  1219.  
  1220.                               omitting the character 'S' selects the
  1221.  
  1222.                               non-shifted function key
  1223.  
  1224.                          t = 'L' if text is transmitted to terminal only;
  1225.  
  1226.                               omitting the character 'L' selects
  1227.  
  1228.                               transmission of the text to the computer
  1229.  
  1230.                          n = number of function key (1 to 16)
  1231.  
  1232.                          <text> = text of function key
  1233.  
  1234.  
  1235.  
  1236.                Comments:
  1237.  
  1238.  
  1239.  
  1240.                     The  function  key  definition   command   allows   the
  1241.  
  1242.                programmer  to  define text strings to be sent to the remote
  1243.  
  1244.                computer or executed locally by the terminal.
  1245.  
  1246.  
  1247.  
  1248.                     In sending text strings to the remote computer,  it  is
  1249.  
  1250.                frequently  useful  to terminate the text strings in certain
  1251.  
  1252.                ways, namely with a carriage return or a space.  To do this,
  1253.  
  1254.                the  escape sequences come in handy.  The characters '^M' or
  1255.  
  1256.                '^m' represent the carriage return, and  '\ '  represents  a
  1257.  
  1258.                space.
  1259.  
  1260.  
  1261.  
  1262.                     In sending commands to the terminal, it  is  frequently
  1263.  
  1264.                useful  to  be  able  to  define  the ESCAPE character.  The
  1265.  
  1266.                sequence '\E' represents the ESCAPE  character.   Also,  the
  1267.  
  1268.                sequence  '\D'  represents the DELETE character (if you ever
  1269.  
  1270.                need it).
  1271.  
  1272.  
  1273.  
  1274.                     See the section on  Text  Output  Convention  for  more
  1275.                                         ____  ______  __________
  1276.  
  1277.                detail.
  1278.  
  1279.  
  1280.  
  1281.                     If both 'S' and 'L' options are  given,  the  order  in
  1282.  
  1283.                which they are presented is not significant.
  1284.  
  1285.  
  1286.  
  1287.                Examples:
  1288.  
  1289.                     F 1 dir^M <-- function key 1 (unshifted) sends
  1290.  
  1291.                                    'dir' followed by a carriage
  1292.  
  1293.                                    return to the computer
  1294.  
  1295.                     Fs 1 dir\ <-- function key 1 (shifted) sends
  1296.  
  1297.                                    'dir' followed by a space
  1298.  
  1299.                                    to the computer
  1300.  
  1301.                     FL 2 \E[2J     <-- function key 2 sends ESCAPE
  1302.  
  1303.                                    followed by '[2J' to the
  1304.  
  1305.                                    terminal
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.                P970 - A Utility for Programming the TVI 970          Page 7
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.                5.  K - Engage/Disengage Key Click
  1318.                    _ _ ________________ ___ _____
  1319.  
  1320.  
  1321.  
  1322.                Syntax:
  1323.  
  1324.                     Kk
  1325.  
  1326.                          k = 'Y' to enable key click
  1327.  
  1328.                          k = anything else to disable key click
  1329.  
  1330.  
  1331.  
  1332.                Comments:
  1333.  
  1334.  
  1335.  
  1336.                     The key click is enabled or disabled by this command.
  1337.  
  1338.  
  1339.  
  1340.                Examples:
  1341.  
  1342.                     K    <-- disable key click
  1343.  
  1344.                     Ky   <-- enable key click
  1345.  
  1346.  
  1347.  
  1348.  
  1349.  
  1350.                6.  L - Select the 25th Line
  1351.                    _ _ ______ ___ ____ ____
  1352.  
  1353.  
  1354.  
  1355.                Syntax:
  1356.  
  1357.                     Ll
  1358.  
  1359.                          l = 'U' selects the User Message
  1360.  
  1361.                          l = 'S' selects the Status Message
  1362.  
  1363.                          l = anything else blanks out the 25th line
  1364.  
  1365.  
  1366.  
  1367.                Comments:
  1368.  
  1369.  
  1370.  
  1371.                     The L command selects  the  25th  line.   Since  it  is
  1372.  
  1373.                executed  as  soon  as  it is encountered, the L command may
  1374.  
  1375.                also be used to blank out the message  line,  load  it,  and
  1376.  
  1377.                then enable it when the processing is done.
  1378.  
  1379.  
  1380.  
  1381.                Examples:
  1382.  
  1383.  
  1384.  
  1385.                     1.  Sequence --
  1386.  
  1387.                          L         <-- blank out 25th line
  1388.  
  1389.                          Umy message    <-- store 'my message' in User Msg
  1390.  
  1391.                          LU        <-- enable User Msg on 25th line
  1392.  
  1393.                     2.  Sequence --
  1394.  
  1395.                          LS        <-- enable status msg on 25th line
  1396.  
  1397.  
  1398.  
  1399.  
  1400.  
  1401.                7.  O - Output any Text to the Terminal
  1402.                    _ _ ______ ___ ____ __ ___ ________
  1403.  
  1404.  
  1405.  
  1406.                Syntax:
  1407.  
  1408.  
  1409.  
  1410.                     O<text>
  1411.  
  1412.  
  1413.  
  1414.                Comments:
  1415.  
  1416.  
  1417.  
  1418.                     The O command simply outputs the following text to  the
  1419.  
  1420.                user's  terminal.   Any  escape  sequence not covered by the
  1421.  
  1422.                other commands can be sent to the terminal rather easily.
  1423.  
  1424.  
  1425.  
  1426.                Examples:
  1427.  
  1428.                     O\E[2J    <-- clear screen
  1429.  
  1430.                P970 - A Utility for Programming the TVI 970          Page 8
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.                     OHello, world  <-- print message
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.                8.  P - Program the Programmable Keys
  1443.                    _ _ _______ ___ ____________ ____
  1444.  
  1445.  
  1446.  
  1447.                Syntax:
  1448.  
  1449.  
  1450.  
  1451.                     P n <text>
  1452.  
  1453.  
  1454.  
  1455.                Comments:
  1456.  
  1457.  
  1458.  
  1459.                     The P command programs the programmable  key  indicated
  1460.  
  1461.                with  the  indicated  character  sequence.  It is the user's
  1462.  
  1463.                responsibility to ensure that the  character  sequence  fits
  1464.  
  1465.                within the key's buffer.  Any escape sequence not covered by
  1466.  
  1467.                the other commands  can  be  sent  to  the  terminal  rather
  1468.  
  1469.                easily.
  1470.  
  1471.  
  1472.  
  1473.                     The value of "n" is the PS number of the key (from 0 to
  1474.  
  1475.                62).  Refer to pages 99-100 of the TVI 970 Operator's Manual
  1476.  
  1477.                (Programming the Programmable Keys)  for  details  on  these
  1478.  
  1479.                values.
  1480.  
  1481.  
  1482.  
  1483.                Examples:
  1484.  
  1485.  
  1486.  
  1487.                     P 24 ^B   <-- change left arrow to ^B
  1488.  
  1489.                     P 19 \EV  <-- change shifted up arrow to ESC V
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.                9.  U - Set the User Message on the 25th Line
  1496.                    _ _ ___ ___ ____ _______ __ ___ ____ ____
  1497.  
  1498.  
  1499.  
  1500.                Syntax:
  1501.  
  1502.  
  1503.  
  1504.                     U<text>
  1505.  
  1506.  
  1507.  
  1508.                Comments:
  1509.  
  1510.  
  1511.  
  1512.                     The text immediately following the letter U  is  output
  1513.  
  1514.                into  the  user message.  The L command must also select the
  1515.  
  1516.                User Message for this output to appear on  the  screen  (see
  1517.  
  1518.                the L command below).
  1519.  
  1520.  
  1521.  
  1522.                     Your VAX/VMS environment should be set up  with  NOWRAP
  1523.  
  1524.                as  a  terminal  characteristic if your User Message is very
  1525.  
  1526.                long.  P970 uses the "normal" technique  of  generating  the
  1527.  
  1528.                User Message, which involves translating each character into
  1529.  
  1530.                a sequence of ASCII digits and outputting up to three digits
  1531.  
  1532.                followed  by  a semicolon for each character.  Consequently,
  1533.  
  1534.                the output to program a User Message tends to  become  quite
  1535.  
  1536.                long,  and  if WRAP is set on your terminal characteristics,
  1537.  
  1538.                the message will be cut short when the number of  characters
  1539.  
  1540.                output  equals  the  number  of  columns  on  your terminal.
  1541.  
  1542.                However, even with NOWRAP enabled, the  next  limitation  is
  1543.  
  1544.                the  size  of  the output buffer.  This limitation allows on
  1545.  
  1546.                the order of 40 characters maximum in the User Message.
  1547.  
  1548.                P970 - A Utility for Programming the TVI 970          Page 9
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.                     To enable NOWRAP on your terminal, have your  LOGIN.COM
  1555.  
  1556.                file issue the following command:  "SET TERMINAL/NOWRAP"
  1557.  
  1558.  
  1559.  
  1560.                Examples:
  1561.  
  1562.                     Umy message    <-- store 'my message' in user line
  1563.  
  1564.                P970 - A Utility for Programming the TVI 970         Page 10
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.                                 Sample Configuration Files
  1571.                                 ______ _____________ _____
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.                FILE 1:
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.                     ; User line blank, keyclick off, define user message,
  1586.  
  1587.                     ;   set 25th line to user message
  1588.  
  1589.                     L
  1590.  
  1591.                     K
  1592.  
  1593.                     uD  Dir  ChDir  Who
  1594.  
  1595.                     Lu
  1596.  
  1597.                     ; Define function keys
  1598.  
  1599.                     F 1 d^M
  1600.  
  1601.                     Fs 1 d\ 
  1602.  
  1603.                     F 2 dir^M
  1604.  
  1605.                     F 3 cd\ 
  1606.  
  1607.                     F 4 who^M
  1608.  
  1609.                     fL 16 \E[0U
  1610.  
  1611.                     fsL 16 \E[0V
  1612.  
  1613.                     ; Define cursor
  1614.  
  1615.                     C
  1616.  
  1617.                     ; Print message
  1618.  
  1619.                     O\E[2J Welcome, Rick
  1620.  
  1621.                     ; Done
  1622.  
  1623.                     E
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.                FILE 2:
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.                     ; Define user message line
  1638.  
  1639.                     U1=Dir  2=CD  3=Who
  1640.  
  1641.                     ; Define function keys
  1642.  
  1643.                     Fn 1 d^m
  1644.  
  1645.                     fs 1 d\ 
  1646.  
  1647.                     fn 2 cd\ 
  1648.  
  1649.                     fs 2 pwd^M
  1650.  
  1651.                     fn 3 who^m
  1652.  
  1653.                     ; Define cursor
  1654.  
  1655.                     cb
  1656.  
  1657.                     ; Done
  1658.  
  1659.                     e
  1660.  
  1661.                     These lines which follow the E command may
  1662.  
  1663.                     contain any text desired by the user
  1664.  
  1665.  
  1666.  
  1667.  
  1668.  
  1669.  
  1670.  
  1671.                P970 - A Utility for Programming the TVI 970         Page 11
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677.                FILE 3:
  1678.  
  1679.  
  1680.  
  1681.  
  1682.  
  1683.                     ; TVI 970 configuration file for Rick Conn
  1684.  
  1685.                     ; Set the Answerback message:
  1686.  
  1687.                     Ac mcacsl^M^M
  1688.  
  1689.                     ; Program the user message:
  1690.  
  1691.                     L
  1692.  
  1693.                     u1=D  2=Dir  3=CD  4=Who
  1694.  
  1695.                     Lu
  1696.  
  1697.                     ; Turn off key click
  1698.  
  1699.                     K
  1700.  
  1701.                     ; Define Function Keys
  1702.  
  1703.                     ;  1 = d<CR>
  1704.  
  1705.                     ;  1 shifted = d<SP>
  1706.  
  1707.                     ;  2 = dir<CR>
  1708.  
  1709.                     ;  3 = cd<SP>
  1710.  
  1711.                     ;  4 = who<CR>
  1712.  
  1713.                     ; 15 = smooth scroll
  1714.  
  1715.                     ; 15 shifted = jump scroll
  1716.  
  1717.                     ; 16 = advance to next page
  1718.  
  1719.                     ; 16 shifted = backup to last page
  1720.  
  1721.                     F 1 d^M
  1722.  
  1723.                     Fs 1 d\ 
  1724.  
  1725.                     F 2 dir^M
  1726.  
  1727.                     F 3 cd\ 
  1728.  
  1729.                     F 4 who^M
  1730.  
  1731.                     FL 15 \E[?4h
  1732.  
  1733.                     FLS 15 \E[?4l
  1734.  
  1735.                     fL 16 \E[0U
  1736.  
  1737.                     fsL 16 \E[0V
  1738.  
  1739.                     ; Set Cursor to Blinking Underline
  1740.  
  1741.                     C
  1742.  
  1743.                     ; Clear Screen and Print Message
  1744.  
  1745.                     O\E[2J Welcome, Rick
  1746.  
  1747.                     ; Done
  1748.  
  1749.                     E
  1750.  
  1751. ::::::::::
  1752. p970.hlp
  1753. ::::::::::
  1754. 1 P970
  1755. COMMAND NAME: P970 or H970
  1756. SYNTAX:
  1757.     P970 filename.typ
  1758. or    H970 filename.typ
  1759. PURPOSE:
  1760.     P970 programs various attributes of the Televideo 970 terminal
  1761. according to commands in the indicated file.  The command "P970" looks
  1762. for the file in the current (or indicated directory), while the command
  1763. "H970" looks for the file in the directory [CONN.P970].  A directory
  1764. prefix should not be used with the H970 command.
  1765.  
  1766. EXAMPLES:
  1767.     P970 setup1.970
  1768.         -- program the TVI970 from the file SETUP1.970 in
  1769.             the current directory
  1770.     H970 login.970
  1771.         -- program the TVI970 from the file LOGIN.970 in [CONN.P970]
  1772.  
  1773. 2 COMMANDS
  1774.  
  1775.     The following is a brief summary of the commands which may be
  1776. placed into a text file which is later read by P970 to program the terminal.
  1777. Details on these commands are available elsewhere in this HELP file.
  1778.  
  1779. Command        Function
  1780. -------        --------
  1781. ;<text>          Comment Line
  1782. A<text>         Load Answerback Message
  1783. Ccr             Cursor Type Selection
  1784. Fst n <text>    Load Function Key
  1785. KY or K          Enable/Disable Key Click
  1786. LU, LS, or L    Select User Message, Status Message or Blank Message
  1787. O<text>         Output any text
  1788. P n <text>       Program the Programmable Keys
  1789. U<text>          Load User Message
  1790. E<text>        End of P970 Command Lines
  1791.  
  1792.     See the P970 manual for details with examples of each of these
  1793. commands.
  1794.  
  1795. 1 E
  1796. P970 Command: E
  1797. Syntax: E<text>
  1798. Function:
  1799.     E indicates the end of the P970 command lines.  Any text which
  1800. follows the letter E and any lines which follow the line containing this
  1801. command are flushed.
  1802.  
  1803. 1 U
  1804. P970 Command: U
  1805. Syntax: U<text>
  1806. Function:
  1807.     U stores the text which immediately follows it in the User
  1808. Message.
  1809.     The LU command has to be issued to turn on the User Message.
  1810.  
  1811. 1 L
  1812. P970 Command: L
  1813. Syntax: Ll
  1814.         l=U to select User Message
  1815.         l=S to select Status Message
  1816.         l=other to select blank message
  1817. Function:
  1818.     L selects which of the three message lines will appear on the 25th
  1819. line of the screen.
  1820.  
  1821. 1 K
  1822. P970 Command: K
  1823. Syntax: Kk
  1824.         k=Y to enable Key Click
  1825.         k=other to disable Key Click
  1826. Function:
  1827.     K enables and disables the key click at the user's terminal.
  1828.  
  1829. 1 F
  1830. P970 Command: F
  1831. Syntax: Fst n <text>
  1832.         s=S if function key is shifted; omitting the char 'S'
  1833.             selects the non-shifted function key
  1834.         t=L to transmit the key string to the terminal only (local);
  1835.             omitting the char 'L' transmits the key string
  1836.             to the computer
  1837.         n=# (number of function key, from 1 to 16); this is required
  1838.         <text> is the text to store in the function key
  1839. Function:
  1840.     F stores text in the function keys.  Any ASCII character from 0
  1841. to 127 (7-bit ASCII) may be stored by this command.
  1842.  
  1843. 1 C
  1844. P970 Command: C
  1845. Syntax: Ccr
  1846.         c=B for block cursor; omitting the char 'B' selects an
  1847.             underline cursor
  1848.         r=S for steady cursor; omitting the char 'S' selects a
  1849.             blinking cursor
  1850. Function:
  1851.     C selects the cursor type.
  1852.  
  1853. 1 A
  1854. P970 Command: A
  1855. Syntax: A<text>
  1856. Function:
  1857.     A programs the answerback sequence.  This sequence is sent to
  1858. the computer by striking Control-BREAK.  It is at most 24 chars long.
  1859.  
  1860. 1 P
  1861. P970 Command: P
  1862. Syntax: P n <text>
  1863.         n=# (programmable key number, from 0 to 62)
  1864. Function:
  1865.     P stores the text into the programmable key indicated by 'n'.
  1866. The number of characters which may be stored varies with the key selected.
  1867. See the section on "Personalizing the 970" - "Programming the Keys" in
  1868. your TVI 970 manual for further details on key numbers and char sequence
  1869. lengths.
  1870.  
  1871. 1 O
  1872. P970 Command: O
  1873. Syntax: O<text>
  1874. Function:
  1875.     O outputs the following text to the terminal with a minimum
  1876. of interpretation.  Functions such as clear screen and message display
  1877. can be performed using this command.
  1878.  
  1879. 1 TEXT
  1880.  
  1881.     Several P970 commands, namely A, F, O, P and U, have an argument
  1882. which is a sequence of characters (indicated by <text> in the syntax
  1883. descriptions in this HELP file).  Any 7-bit ASCII character may be
  1884. represented in this text.  The following rules apply:
  1885.  
  1886.         ^c (uparrow, char) - output control char
  1887.         \D - output DELETE char (7F Hex)
  1888.         \E - output ESCAPE char (1B Hex)
  1889.         \c - output char 'c' literally
  1890.             '\^' outputs '^'
  1891.             '\\' outputs '\'
  1892.  
  1893.     Any character following an uparrow (^) or backslash (\)
  1894. will be capitalized if it is lower-case alphabetic.  See the section
  1895. on CHARS for a summary of all possible characters which can be output.
  1896.  
  1897. 1 CHARS
  1898.  
  1899.  Character    Required        This table summarizes the character
  1900.   Desired     Character        sequences required to output any of
  1901.  Hex ASCII    Sequence        the 128 7-bit ASCII characters.
  1902.  ---------    ---------
  1903.  00   NUL       ^@
  1904.  01   SOH       ^A
  1905.     ...           ..
  1906.  1A   SUB       ^Z
  1907.  1B   ESC       ^[ (note: \E also works)
  1908.  1C   FS       ^\
  1909.  1D   GS       ^]
  1910.  1E   RS       ^^
  1911.  1F   US       ^_
  1912.  20   SP
  1913.  21    !        !
  1914.     ...           ..
  1915.  7E    ~        ~
  1916.  7F   DEL       \D (note: special sequence)
  1917. ::::::::::
  1918. p970.pas
  1919. ::::::::::
  1920. program prog970 (input, output);
  1921. {
  1922.     PROG970.PAS  by Rick Conn
  1923.  
  1924.     The purpose of PROG970 is to Program the TVI 970 terminal from a file,
  1925.     setting a variety of its features.  These features include
  1926.     the following:
  1927.  
  1928.         o User Message Line
  1929.         o Function Keys
  1930.         o Cursor Type
  1931.         o Key Click
  1932.         o 25th Line Display
  1933.         o Answerback Sequence
  1934.         o Programmable Keys
  1935.         o Personal Messages
  1936.         o Other User-Definable Char Sequences
  1937.  
  1938.     PROG970 is divided into three major modules and one initialization
  1939.     and command selection mainline.  The three major modules are:
  1940.  
  1941.         1. Support Routines
  1942.             -- provide low-level I/O et al
  1943.             -- routines are dependent and ordered
  1944.         2. Routines for Terminal Output of Functions
  1945.             -- function-specific routines, such as
  1946.                 program function key n with string s
  1947.             -- routines are independent; order is alphabetical
  1948.             -- routines in module 1 called for support
  1949.         3. Command Processing Routines
  1950.             -- process command options and data for
  1951.                 specific commands
  1952.             -- routines are independent; order is alphabetical
  1953.             -- routines in modules 1 and 2 called for support
  1954.  
  1955. }
  1956.  
  1957. const
  1958.     version = 1.6;      { version number }
  1959.     str_length = 255;   { max length of strings }
  1960.     prompt_length = 17; { length of prompt string }
  1961.     delete = chr(127);  { DELETE character }
  1962.     escape = chr(27);   { ESCAPE character }
  1963.     cr = chr(13);       { CARRIAGE RETURN character }
  1964.     literal = '\';      { following char is accepted literally }
  1965.     control = '^';      { control char is represented }
  1966.     lit_esc = 'E';      { literal code for ESC char (\E) }
  1967.     lit_del = 'D';      { literal code for DEL char (\D) }
  1968.  
  1969. type
  1970.     str = packed array [1..str_length] of char;
  1971.     prompt_str = packed array [1..prompt_length] of char;
  1972.     cptr = ^char;
  1973. var
  1974.     message    : str;
  1975.     infile, fo : TEXT;
  1976.  
  1977. procedure lib$get_foreign (%descr line1 : str; %descr line2 : prompt_str);
  1978.     extern;
  1979.  
  1980. {----------------------------------------------------------------}
  1981. {
  1982.     1. Support Routines
  1983.         STOP_ALL
  1984.         UP
  1985.         TOUPPER
  1986.         DIGOUT
  1987.         CHAROUT
  1988.         PRINT_MESSAGE
  1989.         GET_MESSAGE
  1990.         GET_CHAR
  1991. }
  1992.  
  1993. procedure stop_all;
  1994. {
  1995.     STOP_ALL halts execution of the program when an EOF condition
  1996.     is detected prematurely.  It prints an appropriate error message.
  1997.  
  1998.     Inputs: None
  1999.     Outputs: None
  2000.     Side Effects: None (program is halted)
  2001. }
  2002. begin
  2003.     writeln;
  2004.     writeln ('Premature End of File on Input File');
  2005.     halt
  2006. ;
  2007. end;
  2008.  
  2009.  
  2010. procedure up;
  2011. {
  2012.     UP moves cursor up one line so screen info is not lost by
  2013.     running P970.
  2014.  
  2015.     Inputs: None
  2016.     Outputs: None
  2017.     Side Effects: None (cursor moves up)
  2018. }
  2019. begin
  2020.     write(fo, escape, 'M');   { \E M moves cursor up one line }
  2021. end;
  2022.  
  2023.  
  2024. function toupper (ch : char) : char;
  2025. {
  2026.     TOUPPER capitalizes the input character, if necessary.
  2027.  
  2028.     Inputs:  CH = char to capitalize
  2029.     Outputs:  TOUPPER = capitalized output
  2030.     Side Effects:  None
  2031. }
  2032. begin
  2033.     if (ord('a') <= ord(ch)) AND (ord(ch) <= ord('z')) then
  2034.         toupper := chr(ord(ch) - ord('a') + ord('A'))
  2035.       else
  2036.         toupper := ch;
  2037. end;  { TOUPPER }
  2038.  
  2039.  
  2040. procedure digout (dig : integer);
  2041. {
  2042.     DIGOUT outputs the digit (whose value must be in the range from
  2043.     0 to 9) to the terminal as a single ASCII character (from '0' to
  2044.     '9').
  2045.  
  2046.     Inputs:  DIG = integer from 0 to 9
  2047.     Outputs:  None (char is printed)
  2048.     Side Effects:  None
  2049. }
  2050. begin
  2051.     write(fo, chr(dig + ord('0')) );
  2052. end;  { DIGOUT }
  2053.  
  2054.  
  2055. procedure charout (ch : char);
  2056. {
  2057.     CHAROUT outputs the character to the terminal as up to three
  2058.     ASCII digit characters.  These characters represent the ASCII
  2059.     code value of the input character.  For example, 'A' = 65 decimal,
  2060.     so CHAROUT('A') outputs '65'.
  2061.  
  2062.     Inputs:  CH = char to output
  2063.     Outputs:  None (digit chars are printed)
  2064.     Side Effects:  None
  2065. }
  2066. var
  2067.     ch_val : integer;
  2068.     leading_zero : boolean;
  2069. begin
  2070.     ch_val := ord(ch);
  2071.     leading_zero := TRUE;
  2072.  
  2073.     if (ch_val > 99) then begin  { process 100's }
  2074.         leading_zero := FALSE;
  2075.         digout (ch_val div 100);  { output 100's digit }
  2076.         ch_val := ch_val - (ch_val div 100)*100;  { take away 100's }
  2077.         end;
  2078.  
  2079.     if (ch_val > 9) then begin  { process 10's }
  2080.         digout (ch_val div 10);  { output 10's digit }
  2081.         ch_val := ch_val - (ch_val div 10)*10;  { take away 10's }
  2082.         end
  2083.     else if (NOT leading_zero) then write(fo,'0');  { output embedded '0' }
  2084.  
  2085.     digout (ch_val);  { output 1's }
  2086. end;  { CHAROUT }
  2087.  
  2088.  
  2089. procedure print_message;
  2090. {
  2091.     PRINT_MESSAGE prints the message contained in the array MESSAGE
  2092.     to the screen.
  2093.  
  2094.     Inputs:  MESSAGE = string passed globally
  2095.     Outputs:  None (string is printed)
  2096.     Side Effects:  None
  2097. }
  2098. var
  2099.     ctrl, idx : integer;
  2100.  
  2101. begin
  2102.     idx := 1;
  2103.     while (message[idx] <> chr(0)) do begin
  2104.         case message[idx] of
  2105.             control : begin  { control char processing }
  2106.                 idx := idx + 1;  { next char }
  2107.                 ctrl := ord(toupper(message[idx])) - ord('@');
  2108.                 charout (chr(ctrl));
  2109.                 end;
  2110.             literal : begin  { literal char follows }
  2111.                 idx := idx + 1;  { next char }
  2112.                 case toupper(message[idx]) of
  2113.                     lit_del : charout (delete);
  2114.                     lit_esc : charout (escape);
  2115.                     OTHERWISE charout (message[idx]);
  2116.                     end;
  2117.                 end;
  2118.             OTHERWISE charout (message[idx]);  { output char }
  2119.             end;  { case message[idx] }
  2120.         idx := idx + 1;
  2121.         if (message[idx] <> chr(0)) then write (fo,';');  { separator }
  2122.         end;
  2123. end;  { PRINT_MESSAGE }
  2124.  
  2125.  
  2126. procedure get_message;
  2127. {
  2128.     GET_MESSAGE clears the message buffer and reads a line
  2129.     of text from the keyboard into it.
  2130.  
  2131.     Inputs:  None (keyboard)
  2132.     Outputs:  MESSAGE (global) = user input followed by NULLs
  2133.     Side Effects:  None
  2134. }
  2135. var
  2136.     idx : integer;
  2137. begin
  2138.     if EOF(infile) then for idx:=1 to str_length do message[idx]:=' '
  2139.       else readln (infile, message);
  2140.     idx := str_length;
  2141.     while ((message[idx] = ' ') AND (idx <> 1)) do begin
  2142.         message[idx] := chr(0);  { NULL fill at end }
  2143.         idx := idx - 1;
  2144.         end;
  2145.     if (message[idx] = literal) then begin  { last char was a space }
  2146.         idx := idx + 1;
  2147.         message[idx] := ' ';
  2148.         end;
  2149. end;  { GET_MESSAGE }
  2150.  
  2151.  
  2152. function get_char : char;
  2153. {
  2154.     GET_CHAR inputs a line from the user and returns only the first
  2155.     character of it (non-blank).
  2156.  
  2157.     Inputs:  None (keyboard)
  2158.     Outputs:  Char returned
  2159.     Side Effects:  None
  2160. }
  2161. var
  2162.     message_save : str;
  2163.     idx : integer;
  2164. begin
  2165.     for idx := 1 to str_length do message_save[idx] := message[idx];
  2166.     get_message;
  2167.     idx := 1;
  2168.     while (message[idx] = ' ') do idx := idx + 1;  { skip to non-blank }
  2169.     get_char := message[idx];  { set return char }
  2170.     for idx := 1 to str_length do message[idx] := message_save[idx];
  2171. end;  { GET_CHAR }
  2172.  
  2173. {----------------------------------------------------------------}
  2174. {
  2175.     2. Routines for Terminal Output of Functions
  2176.         ANSWER_BACK
  2177.         CURSOR
  2178.         FUNCTION_KEY
  2179.         KEY_CLICK
  2180.         LINE_TYPE
  2181.         OTHER_TEXT
  2182.         PERSONAL_MESSAGE
  2183.         PROGRAM_KEYS (not yet used)
  2184.         USER_LINE
  2185. }
  2186.  
  2187. procedure answer_back;
  2188. {
  2189.     ANSWER_BACK programs the answer-back string with the message
  2190.     contained in the message buffer.  It is assumed that the message
  2191.     is 24 characters or less.
  2192.  
  2193.     Inputs:  MESSAGE (global) = string to be placed in message line
  2194.     Outputs:  None (Message is stored)
  2195.     Side Effects:  None
  2196. }
  2197. begin
  2198.     write (fo, escape);   { send ESCAPE char }
  2199.     write (fo, '\72;');   { store Answer Back Message }
  2200.     print_message;    { output message }
  2201.     writeln(fo); up;  { new line to end sequence }
  2202. end;  { USER_LINE }
  2203.  
  2204.  
  2205.  
  2206. procedure cursor (ctype : char);
  2207. {
  2208.     CURSOR programs the cursor type.
  2209.  
  2210.     Inputs:  CTYPE = cursor type ('0'=blinking block, '1'=steady block,
  2211.         '2'=blinking underline, '3'=steady underline)
  2212.     Outputs:  None (cursor is set)
  2213.     Side Effects:  None
  2214. }
  2215. begin
  2216.     write (fo, escape);  { ESCAPE char }
  2217.     write (fo, '[3;');   { set cursor }
  2218.     write (fo, ctype);   { cursor type }
  2219.     write (fo, 'z');     { done }
  2220. end;  { CURSOR }
  2221.  
  2222.  
  2223. procedure function_key (key : integer; shifted, xmit : boolean);
  2224. {
  2225.     FUNCTION_KEY programs a function key with the string contained
  2226.     in MESSAGE.
  2227.  
  2228.     Inputs:  MESSAGE (global) = message to go into function key
  2229.          KEY = number of function key (1 to 16)
  2230.          SHIFTED = is function key shifted (T/F)?
  2231.          XMIT = transmit string to computer (T/F)?
  2232.     Outputs:  None (key is programmed)
  2233.     Side Effects:  None
  2234. }
  2235. begin
  2236.     write (fo, escape);  { send ESCAPE char }
  2237.     write (fo, '|');     { programming function key }
  2238.     if (shifted) then charout (chr(key+16))  { shifted key number }
  2239.       else charout (chr(key));  { unshifted key number }
  2240.     write (fo, ';');     { separator }
  2241.         if (xmit) then write (fo, '1')  { full duplex - send to computer only }
  2242.       else write (fo, '2');  { local }
  2243.     write (fo, ';');     { separator }
  2244.     print_message;       { send message }
  2245.     writeln(fo); up;     { new line to end sequence }
  2246. end;  { FUNCTION_KEY }
  2247.  
  2248.  
  2249. procedure key_click (click : boolean);
  2250. {
  2251.     KEY_CLICK turns on the key click if CLICK is TRUE or off the
  2252.     key click if CLICK is FALSE.
  2253.  
  2254.     Inputs:  CLICK = T if key click ON, F if key click OFF
  2255.     Outputs:  None
  2256.     Side Effects:  None (key click is affected)
  2257. }
  2258. begin
  2259.     if (click) then begin  { turn on key click }
  2260.         write (fo, escape);
  2261.         writeln (fo, '[6;0z'); up;
  2262.         end
  2263.       else begin           { turn off key click }
  2264.         write (fo, escape);
  2265.         writeln (fo, '[6;1z'); up;
  2266.         end;
  2267. end;  { KEY_CLICK }
  2268.  
  2269.  
  2270. procedure line_type (selection : integer);
  2271. {
  2272.     LINE_TYPE selects the 25th line as blank, status, or user
  2273.     message.
  2274.  
  2275.     Inputs:  SELECTION = type (0=blank, 1=status, 2=user message)
  2276.     Outputs:  None
  2277.     Side Effects:  None (line type is selected)
  2278. }
  2279. begin
  2280.     write (fo, escape);  { ESCAPE char }
  2281.     write (fo, '[0;');   { prefix }
  2282.     write (fo, chr(selection + ord('0')));  { digit char '0', '1', '2' }
  2283.     writeln (fo, 'z'); up;
  2284. end;  { LINE_TYPE }
  2285.  
  2286.  
  2287. procedure other_text;
  2288. {
  2289.     OTHER_TEXT simply echoes the text which follows the O command
  2290.     as-is (with escape sequence processing).
  2291.  
  2292.     Inputs:  None
  2293.     Outputs:  None
  2294.     Side Effects:  None (text is sent to terminal)
  2295. }
  2296. var
  2297.     idx : integer;
  2298.     chx : char;
  2299. begin
  2300.     idx := 1;
  2301.     repeat
  2302.         case toupper(message[idx]) of
  2303.             control : begin  { output control char }
  2304.                 idx := idx + 1;
  2305.                 chx := toupper(message[idx]);
  2306.                 chx := chr(ord(chx)-ord('@'));
  2307.                 write (fo, chx);
  2308.                 end;
  2309.             literal : begin  { output literal char }
  2310.                 idx := idx + 1;
  2311.                 chx := message[idx];
  2312.                 case toupper(chx) of
  2313.                     lit_del : write (fo, delete);
  2314.                     lit_esc : write (fo, escape);
  2315.                     OTHERWISE write (fo, chx);
  2316.                     end;
  2317.                 end;
  2318.             OTHERWISE write (fo, message[idx]);
  2319.             end;
  2320.         idx := idx + 1;
  2321.     until (message[idx] = chr(0));
  2322. end;  { OTHER_TEXT }
  2323.  
  2324. procedure personal_message (msg : integer);
  2325. {
  2326.     PERSONAL_MESSAGE loads a personal message into the terminal.
  2327.     It is the user's responsibility to ensure that the personal
  2328.     message does not exceed 9 characters in length.
  2329.  
  2330.     Inputs:  MESSAGE (global) = message to go into terminal
  2331.          MSG = Personal Message Number (0 to 7)
  2332.     Outputs:  None (message is programmed)
  2333.     Side Effects:  None
  2334. }
  2335. begin
  2336.     write (fo, escape);      { send ESCAPE char }
  2337.     write (fo, '^');         { personal message }
  2338.     charout (chr(msg+64));   { PS number for message }
  2339.     write (fo, ';');         { separator }
  2340.     print_message;           { send message }
  2341.     writeln(fo); up;         { new line to end sequence }
  2342. end;  { PERSONAL_MESSAGE }
  2343.  
  2344. procedure program_keys (ps : integer);
  2345. {
  2346.     PROGRAM_KEYS programs a user-programmable key with a character
  2347.     sequence.  It is the programmer's responsibility to ensure that
  2348.     no more than the maximum number of bytes allowed for a particular
  2349.     key are transmitted into it.
  2350.  
  2351.     Inputs:  MESSAGE (global) = message to go into prog key
  2352.          PS = Ps value which identifies key
  2353.     Outputs:  None (key is programmed)
  2354.     Side Effects:  None
  2355. }
  2356. begin
  2357.     write (fo, escape);  { send ESCAPE char }
  2358.     write (fo, '\');     { programming key }
  2359.     charout (chr(ps));   { key identifier }
  2360.     write (fo, ';');     { separator }
  2361.     print_message;       { send message }
  2362.     writeln(fo); up;     { new line to end sequence }
  2363. end;  { PROGRAM_KEYS }
  2364.  
  2365.  
  2366. procedure user_line (double : boolean);
  2367. {
  2368.     USER_LINE programs the User's Message Line on the TVI 970 with
  2369.     the string contained in MESSAGE.  If DOUBLE is TRUE, the message
  2370.     appears as double-width.
  2371.  
  2372.     Inputs:  MESSAGE (global) = string to be placed in message line
  2373.          DOUBLE = is double-width text to be output (T/F)?
  2374.     Outputs:  None (Message is stored)
  2375.     Side Effects:  None
  2376. }
  2377. begin
  2378.     write (fo, escape);   { send ESCAPE char }
  2379.     write (fo, '^');      { store User Line Message }
  2380.     if (double) then begin  { enable double-width chars }
  2381.         write (fo, ' ');  { space to position cursor }
  2382.         write (fo, escape);  { goto double-width }
  2383.         write (fo, '[5;1z');
  2384.         end;
  2385.     print_message;    { output message }
  2386.     if (double) then begin  { enable single-width chars }
  2387.         write (fo, escape);  { goto single-width }
  2388.         write (fo, '[5;0z');
  2389.         end;
  2390.     writeln(fo); up;  { new line to end sequence }
  2391. end;  { USER_LINE }
  2392.  
  2393. {----------------------------------------------------------------}
  2394. {
  2395.     3. Command Processing Routines
  2396.         PROCESS_ANSWER_BACK
  2397.         PROCESS_CURSOR_TYPE
  2398.         PROCESS_FCT_KEY
  2399.         PROCESS_KEY_CLICK
  2400.         PROCESS_LINE_TYPE
  2401.         PROCESS_OTHER_TEXT
  2402.         PROCESS_PERSONAL_MESSAGE
  2403.         PROCESS_PROGRAM_KEYS (not yet used)
  2404.         PROCESS_USER_LINE
  2405. }
  2406.  
  2407. procedure process_answer_back;
  2408. {
  2409.     PROCESS_ANSWER_BACK reads in the answer back message
  2410.     and programs the terminal with it.
  2411.  
  2412.     Inputs:  None
  2413.     Outputs:  None (message is programmed)
  2414.     Side Effects:  None
  2415. }
  2416. begin
  2417.     get_message;   { input message }
  2418.     answer_back;   { send sequence }
  2419. end;  { PROCESS_ANSWER_BACK }
  2420.  
  2421.  
  2422. procedure process_cursor_type;
  2423. {
  2424.     PROCESS_CURSOR_TYPE programs the type of cursor, as selected
  2425.     from the file input.  Syntax:
  2426.  
  2427.         Ccr
  2428.     where:
  2429.         c = B for Block (vs Underline) Cursor
  2430.         r = S for Steady (vs Blinking) Cursor
  2431. }
  2432. var
  2433.     opt : char;
  2434.     idx, ctype : integer;
  2435. begin
  2436.     ctype := 2;  { cursor is blinking underline }
  2437.     get_message; { read line into message buffer }
  2438.     idx := 1;    { 1st char }
  2439.     repeat
  2440.         opt := toupper (message[idx]);  { get next char }
  2441.         idx := idx + 1;
  2442.         case opt of
  2443.             'B' : ctype := ctype - 2;  { block cursor }
  2444.             'S' : ctype := ctype + 1;  { steady cursor }
  2445.             OTHERWISE ;                { NULL statement }
  2446.         end;  { case MESSAGE[IDX] }
  2447.     until (opt = chr(0));
  2448.     cursor (chr(ctype + ord('0')));  { set cursor }
  2449. end;  { PROCESS_CURSOR_TYPE }
  2450.  
  2451.  
  2452. procedure process_fct_key;
  2453. {
  2454.     PROCESS_FCT_KEY programs a function key.  Syntax:
  2455.         Fst n text
  2456.     where:
  2457.         s = S if fct key is shifted
  2458.         t = L if local execution of key (term only)
  2459.         n = function key number (1-16)
  2460.         text = text of key
  2461.  
  2462.     Inputs:  None
  2463.     Outputs:  None
  2464.     Side Effects:  None (Fct Key is programmed)
  2465. }
  2466. var
  2467.     shifted, xmit : boolean;
  2468.     opt : char;
  2469.     key_number : integer;
  2470. begin
  2471.     xmit := TRUE;      { default is xmit to computer }
  2472.     shifted := FALSE;  { default is not shifted fct key }
  2473.     repeat
  2474.         if EOF(infile) then stop_all
  2475.           else read (infile, opt);    { get next char }
  2476.         opt := toupper (opt);         { capitalize }
  2477.         case opt of
  2478.             'L' : xmit := FALSE;    { don't xmit to computer }
  2479.             'S' : shifted := TRUE;  { shift fct key }
  2480.             OTHERWISE ;             { NULL statement }
  2481.         end;  { case OPT }
  2482.     until (opt = ' ');
  2483.     if EOF(infile) then stop_all;
  2484.     read (infile, key_number);   { get number of key }
  2485.     if EOF(infile) then stop_all;
  2486.     read (infile, opt);          { flush following char }
  2487.     get_message;                 { input text }
  2488.     function_key (key_number, shifted, xmit);
  2489. end;  { PROCESS_FCT_KEY }
  2490.  
  2491.  
  2492. procedure process_key_click;
  2493. {
  2494.     PROCESS_KEY_CLICK turns on and off the key click.  Syntax:
  2495.         Kk
  2496.     where:
  2497.         k = Y if key click on (otherwise off)
  2498.  
  2499.     Inputs:  None
  2500.     Outputs:  None
  2501.     Side Effects:  None (key click is affected)
  2502. }
  2503. var
  2504.     click : boolean;
  2505. begin
  2506.     get_message;
  2507.     if (toupper(message[1]) = 'Y') then click := TRUE
  2508.       else click := FALSE;
  2509.     key_click (click);
  2510. end;  { PROCESS_KEY_CLICK }
  2511.  
  2512.  
  2513. procedure process_line_type;
  2514. {
  2515.     PROCESS_LINE_TYPE selects the type of line displayed at the
  2516.     25th line.  Syntax:
  2517.         Ll
  2518.     where:
  2519.         l = U if user, S if status (default is blank)
  2520.  
  2521.     Inputs:  None
  2522.     Outputs:  None
  2523.     Side Effects:  None (line is set)
  2524. }
  2525. var
  2526.     ltype : integer;
  2527. begin
  2528.     get_message;  { input text }
  2529.     case toupper(message[1]) of
  2530.         'U' : ltype := 2;
  2531.         'S' : ltype := 1;
  2532.         OTHERWISE ltype := 0;
  2533.         end;
  2534.     line_type (ltype);  { set line type }
  2535. end;  { PROCESS_LINE_TYPE }
  2536.  
  2537.  
  2538. procedure process_other_text;
  2539. {
  2540.     PROCESS_OTHER_TEXT sends the text following the command
  2541.     to the terminal with escape processing.  Syntax:
  2542.         O<text>
  2543.  
  2544.     Inputs:  None
  2545.     Outputs:  None
  2546.     Side Effects:  None (text is sent to terminal)
  2547. }
  2548. begin
  2549.     get_message;  { input text }
  2550.     other_text;   { output text }
  2551. end;  { PROCESS_OTHER_TEXT }
  2552.  
  2553.  
  2554. procedure process_personal_message;
  2555. {
  2556.     PROCESS_PERSONAL_MESSAGE programs one of the personal messages
  2557.     with a new character string.  The user is responsible for
  2558.     ensuring that the string is not too long for the message's buffer.
  2559.     Syntax:
  2560.         M n text
  2561.     where:
  2562.         n = Message Number (0 to 7)
  2563.         text = text for message
  2564.  
  2565.     Inputs:  None
  2566.     Outputs:  None
  2567.     Side Effects:  None (Message is programmed)
  2568. }
  2569. var
  2570.     opt : char;
  2571.     msg_number : integer;
  2572. begin
  2573.     if EOF(infile) then stop_all;
  2574.     read (infile, msg_number);   { get number of message }
  2575.     if EOF(infile) then stop_all;
  2576.     read (infile, opt);          { flush following char }
  2577.     get_message;                 { input text }
  2578.     personal_message (msg_number);
  2579. end;  { PROCESS_PERSONAL_MESSAGE }
  2580.  
  2581.  
  2582. procedure process_program_keys;
  2583. {
  2584.     PROCESS_PROGRAM_KEYS programs one of the programmable keys
  2585.     with a new character string.  The user is responsible for
  2586.     ensuring that the string is not too long for the key's buffer.
  2587.     Syntax:
  2588.         P n text
  2589.     where:
  2590.         n = Ps value of key (0 to 62)
  2591.         text = text for key
  2592.  
  2593.     Inputs:  None
  2594.     Outputs:  None
  2595.     Side Effects:  None (Key is programmed)
  2596. }
  2597. var
  2598.     opt : char;
  2599.     key_number : integer;
  2600. begin
  2601.     if EOF(infile) then stop_all;
  2602.     read (infile, key_number);   { get number of key }
  2603.     if EOF(infile) then stop_all;
  2604.     read (infile, opt);          { flush following char }
  2605.     get_message;                 { input text }
  2606.     program_keys (key_number);
  2607. end;  { PROCESS_PROGRAM_KEYS }
  2608.  
  2609.  
  2610. procedure process_user_line;
  2611. {
  2612.     PROCESS_USER_LINE inputs the user line and programs the terminal
  2613.     with it.  Syntax:
  2614.         U<text>
  2615.  
  2616.     Inputs:  None
  2617.     Outputs:  None
  2618.     Side Effects:  MESSAGE (global) is changed
  2619. }
  2620. begin
  2621.     get_message;  { input user line }
  2622.     user_line (FALSE);  { program line with normal width chars }
  2623. end;  { PROCESS_USER_LINE }
  2624.  
  2625.  
  2626. {----------------------------------------------------------------}
  2627. { 4. Mainline }
  2628.  
  2629. var
  2630.     cmd : char;
  2631.     fkey : integer;
  2632.     fname : str;
  2633.     prompt : prompt_str;
  2634. value
  2635.     prompt := '$_P970 Filename? ';
  2636.  
  2637. begin  { Mainline  }
  2638.     writeln ('P970 Version ', version:3:1);
  2639.     lib$get_foreign (fname, prompt);  { get file name from command line }
  2640.     open(infile, fname, OLD);         { open command file }
  2641.     reset(infile);                    { rewind command file for input }
  2642.     open(fo,'SYS$OUTPUT', NEW, 4096); { open output file }
  2643.     rewrite(fo);
  2644.     repeat
  2645.         if EOF(infile) then cmd := 'E'
  2646.           else read (infile, cmd);  { get command letter }
  2647.         cmd := toupper (cmd);       { convert to upper case }
  2648.         case cmd of
  2649.             ' ' : get_message;
  2650.             'A' : process_answer_back;
  2651.             'C' : process_cursor_type;
  2652.             'E' : cmd := 'Z';
  2653.             'F' : process_fct_key;
  2654.             'K' : process_key_click;
  2655.             'L' : process_line_type;
  2656.  
  2657. { Personal Messages Not Implemented because of error in manual }
  2658. {            'M' : process_personal_message; }
  2659.  
  2660.             'O' : process_other_text;
  2661.             'P' : process_program_keys;
  2662.             'U' : process_user_line;
  2663.             'Z' : cmd := 'Z';
  2664.             ';' : get_message;
  2665.             OTHERWISE begin
  2666.                 write ('Invalid Command: '); writeln (cmd);
  2667.                 get_message;
  2668.                 end;
  2669.         end;
  2670.     until (cmd = 'Z');
  2671. end.  { PROG970 }
  2672. ::::::::::
  2673. a970.ada
  2674. ::::::::::
  2675.  
  2676. with TEXT_IO;
  2677.  
  2678. procedure PROG970 is
  2679. -- 
  2680. --      PROG970 in Pascal, by Rick Conn
  2681. --               converted to Ada by Freeman Moore, April 1985
  2682. -- 
  2683. --      The purpose of PROG970 is to Program the TVI 970 terminal from a file,
  2684. --      setting a variety of its features.  These features include
  2685. --      the following:
  2686. -- 
  2687. --              o User Message Line
  2688. --              o Function Keys
  2689. --              o Cursor Type
  2690. --              o Key Click
  2691. --              o 25th Line Display
  2692. --              o Answerback Sequence
  2693. --              o Programmable Keys
  2694. --              o Personal Messages
  2695. --              o Other User-Definable Char Sequences
  2696. -- 
  2697. --      PROG970 is divided into three major modules and one initialization
  2698. --      and command selection mainline.  The three major modules are:
  2699. -- 
  2700. --              1. Support Routines
  2701. --                      -- provide low-level I/O et al
  2702. --                      -- routines are dependent and ordered
  2703. --              2. Routines for Terminal Output of Functions
  2704. --                      -- function-specific routines, such as
  2705. --                              program function key n with string s
  2706. --                      -- routines are independent; order is alphabetical
  2707. --                      -- routines in module 1 called for support
  2708. --              3. Command Processing Routines
  2709. --                      -- process command options and data for
  2710. --                              specific commands
  2711. --                      -- routines are independent; order is alphabetical
  2712. --                      -- routines in modules 1 and 2 called for support
  2713. -- 
  2714. -- 
  2715.  
  2716.     VERSION       : constant STRING := "1.7";   -- version number 
  2717.     SYS_OUTPUT    : constant string := "SYS$OUTPUT";  -- user's terminal
  2718.     STR_LENGTH    : constant := 255;   -- max length of strings 
  2719.     PROMPT_LENGTH : constant := 17;    -- length of prompt string 
  2720.     DELETE        : constant CHARACTER := ASCII.DEL; -- DELETE character 
  2721.     ESCAPE        : constant CHARACTER := ASCII.ESC; -- ESCAPE character 
  2722.     CR            : constant CHARACTER := ASCII.CR; -- CARRIAGE RETURN character
  2723.                                                     -- 
  2724.     NUL           : constant CHARACTER := ASCII.NUL; -- used for end of string
  2725.     LITERAL       : constant CHARACTER := '\';   -- following char is accepted
  2726.                                                  -- literally 
  2727.     CONTROL       : constant CHARACTER := '^';   -- control char is represented 
  2728.     LIT_ESC       : constant CHARACTER := 'E';   -- literal code for ESC char
  2729.                                                  -- (\E) 
  2730.     LIT_DEL       : constant CHARACTER := 'D';   -- literal code for DEL char
  2731.                                                  -- (\D) 
  2732.  
  2733.     HALT : exception;
  2734.  
  2735.     subtype STR        is STRING (1 .. STR_LENGTH);
  2736.     subtype PROMPT_STR is STRING (1 .. PROMPT_LENGTH);
  2737.  
  2738.     MESSAGE      : STR;
  2739.     INFILE       : TEXT_IO.FILE_TYPE;
  2740.     FO           : TEXT_IO.FILE_TYPE;
  2741.  
  2742.     CMD          : CHARACTER;
  2743.     FKEY         : INTEGER;
  2744.     FNAME        : STR;
  2745.     FNAME_LENGTH : INTEGER;
  2746.     PROMPT       : constant PROMPT_STR := "$_A970 Filename? ";
  2747.  
  2748.     package INT_IO is new TEXT_IO.INTEGER_IO (INTEGER);
  2749.  
  2750. ------------------------------------------------------------------
  2751. -- 
  2752. --      1. Support Routines
  2753. --              STOP_ALL
  2754. --              UP
  2755. --              TOUPPER
  2756. --              DIGOUT
  2757. --              CHAROUT
  2758. --              PRINT_MESSAGE
  2759. --              GET_MESSAGE
  2760. --              GET_CHAR
  2761. -- 
  2762.  
  2763.     procedure STOP_ALL is
  2764. -- 
  2765. --      STOP_ALL halts execution of the program when an EOF condition
  2766. --      is detected prematurely.  It prints an appropriate error message.
  2767. -- 
  2768. --      Inputs: None
  2769. --      Outputs: None
  2770. --      Side Effects: None (program is halted)
  2771. -- 
  2772.     begin
  2773.         TEXT_IO.NEW_LINE;
  2774.         TEXT_IO.PUT_LINE ("Premature End of File on Input File");
  2775.         raise HALT;
  2776.     end STOP_ALL;
  2777.  
  2778.  
  2779.     procedure UP is
  2780. -- 
  2781. --      UP moves cursor up one line so screen info is not lost by
  2782. --      running P970.
  2783. -- 
  2784. --      Inputs: None
  2785. --      Outputs: None
  2786. --      Side Effects: None (cursor moves up)
  2787. -- 
  2788.     begin
  2789.         TEXT_IO.PUT (FO, ESCAPE & 'M'); -- \E M moves cursor up one line 
  2790.     end UP;
  2791.  
  2792.  
  2793.     function TOUPPER (CH : CHARACTER) return CHARACTER is
  2794. -- 
  2795. --      TOUPPER capitalizes the input character, if necessary.
  2796. -- 
  2797. --      Inputs:  CH = char to capitalize
  2798. --      Outputs:  TOUPPER = capitalized output
  2799. --      Side Effects:  None
  2800. -- 
  2801.         TEMP_CHAR : CHARACTER;
  2802.     begin
  2803.         if (CHARACTER'POS ('a') <= CHARACTER'POS (CH)) and
  2804.            (CHARACTER'POS (CH) <= CHARACTER'POS ('z')) then
  2805.             TEMP_CHAR := CHARACTER'VAL
  2806.                            (CHARACTER'POS (CH) - CHARACTER'POS ('a') +
  2807.                             CHARACTER'POS ('A'));
  2808.         else
  2809.             TEMP_CHAR := CH;
  2810.         end if;
  2811.  
  2812.         return TEMP_CHAR;
  2813.     end TOUPPER;
  2814.  
  2815.  
  2816.     procedure CHAROUT (CH : CHARACTER) is
  2817. -- 
  2818. --      CHAROUT outputs the character to the terminal as up to three
  2819. --      ASCII digit characters.  These characters represent the ASCII
  2820. --      code value of the input character.  For example, 'A' = 65 decimal,
  2821. --      so CHAROUT('A') outputs '65'.
  2822. -- 
  2823. --      Inputs:  CH = char to output
  2824. --      Outputs:  None (digit chars are printed)
  2825. --      Side Effects:  None
  2826. -- 
  2827.         CH_VAL : INTEGER := CHARACTER'POS (CH);
  2828.     begin
  2829.  
  2830.         INT_IO.PUT (FO, CH_VAL, 1);
  2831.  
  2832.     end CHAROUT;
  2833.  
  2834.  
  2835.     procedure PRINT_MESSAGE is
  2836. -- 
  2837. --      PRINT_MESSAGE prints the message contained in the array MESSAGE
  2838. --      to the screen.
  2839. -- 
  2840. --      Inputs:  MESSAGE = string passed globally
  2841. --      Outputs:  None (string is printed)
  2842. --      Side Effects:  None
  2843. -- 
  2844.  
  2845.         CTRL, IDX : INTEGER;
  2846.  
  2847.     begin
  2848.         IDX := 1;
  2849.  
  2850.         while (MESSAGE (IDX) /= NUL) loop
  2851.             case MESSAGE (IDX) is
  2852.                 when CONTROL =>  -- control char processing 
  2853.                     IDX := IDX + 1;             -- next char 
  2854.                     CTRL := CHARACTER'POS (TOUPPER (MESSAGE (IDX))) -
  2855.                             CHARACTER'POS ('@');
  2856.                     CHAROUT (CHARACTER'VAL (CTRL));
  2857.  
  2858.                 when LITERAL =>  -- literal char follows 
  2859.                     IDX := IDX + 1;             -- next char 
  2860.                     case TOUPPER (MESSAGE (IDX)) is
  2861.                         when LIT_DEL =>  CHAROUT (DELETE);
  2862.                         when LIT_ESC =>  CHAROUT (ESCAPE);
  2863.                         when others  =>  CHAROUT (MESSAGE (IDX));
  2864.                     end case;
  2865.  
  2866.                 when others =>  CHAROUT (MESSAGE (IDX));  -- output char 
  2867.             end case;
  2868.             -- 
  2869.             IDX := IDX + 1;
  2870.  
  2871.             if (MESSAGE (IDX) /= NUL) then
  2872.                 TEXT_IO.PUT (FO, ';');                              -- separator
  2873.                                                                     -- 
  2874.             end if;
  2875.         end loop;
  2876.     end PRINT_MESSAGE;
  2877.  
  2878.  
  2879.     procedure GET_MESSAGE is
  2880. -- 
  2881. --      GET_MESSAGE clears the message buffer and reads a line
  2882. --      of text from the keyboard into it.
  2883. -- 
  2884. --      Inputs:  None (keyboard)
  2885. --      Outputs:  MESSAGE (global) = user input followed by NULLs
  2886. --      Side Effects:  None
  2887. -- 
  2888.  
  2889.         IDX : INTEGER;
  2890.     begin
  2891.         MESSAGE := (1 .. STR_LENGTH => ' ');
  2892.  
  2893.         if not TEXT_IO.END_OF_FILE (INFILE) then
  2894.             TEXT_IO.GET_LINE (INFILE, MESSAGE, IDX);
  2895.         end if;
  2896.  
  2897.         IDX := STR_LENGTH;
  2898.  
  2899.         while ((MESSAGE (IDX) = ' ') and (IDX /= 1)) loop
  2900.             MESSAGE (IDX) := NUL;     -- NULL fill at end 
  2901.             IDX := IDX - 1;
  2902.         end loop;
  2903.  
  2904.         if (MESSAGE (IDX) = LITERAL) then
  2905.             -- last char was a space 
  2906.             IDX := IDX + 1;
  2907.             MESSAGE (IDX) := ' ';
  2908.         end if;
  2909.     end GET_MESSAGE;
  2910.  
  2911.  
  2912.     function GET_CHAR return CHARACTER is
  2913. -- 
  2914. --      GET_CHAR inputs a line from the user and returns only the first
  2915. --      character of it (non-blank).
  2916. -- 
  2917. --      Inputs:  None (keyboard)
  2918. --      Outputs:  Char returned
  2919. --      Side Effects:  None
  2920. -- 
  2921.  
  2922.         MESSAGE_SAVE : STR;
  2923.         IDX          : INTEGER;
  2924.         TEMP_CHAR    : CHARACTER;
  2925.     begin
  2926.         MESSAGE_SAVE := MESSAGE;
  2927.         GET_MESSAGE;
  2928.         IDX := 1;
  2929.  
  2930.         while (MESSAGE (IDX) = ' ') loop
  2931.             IDX := IDX + 1;                             -- skip to non-blank 
  2932.         end loop;
  2933.  
  2934.         TEMP_CHAR := MESSAGE (IDX); -- set return char 
  2935.         MESSAGE := MESSAGE_SAVE;
  2936.         return TEMP_CHAR;
  2937.     end GET_CHAR;
  2938.  
  2939. ----------------------------------------------------------------
  2940. -- 
  2941. --      2. Routines for Terminal Output of Functions
  2942. --              ANSWER_BACK
  2943. --              CURSOR
  2944. --              FUNCTION_KEY
  2945. --              KEY_CLICK
  2946. --              LINE_TYPE
  2947. --              OTHER_TEXT
  2948. --              PERSONAL_MESSAGE
  2949. --              PROGRAM_KEYS (not yet used)
  2950. --              USER_LINE
  2951. -- 
  2952.  
  2953.     procedure ANSWER_BACK is
  2954. -- 
  2955. --      ANSWER_BACK programs the answer-back string with the message
  2956. --      contained in the message buffer.  It is assumed that the message
  2957. --      is 24 characters or less.
  2958. -- 
  2959. --      Inputs:  MESSAGE (global) = string to be placed in message line
  2960. --      Outputs:  None (Message is stored)
  2961. --      Side Effects:  None
  2962. -- 
  2963.     begin
  2964.         TEXT_IO.PUT (FO, ESCAPE);  -- send ESCAPE char 
  2965.         TEXT_IO.PUT (FO, "\72;");  -- store Answer Back Message 
  2966.         PRINT_MESSAGE;   -- output message 
  2967.         TEXT_IO.NEW_LINE (FO);
  2968.         UP;                       -- new line to end sequence 
  2969.     end ANSWER_BACK;
  2970.  
  2971.  
  2972.  
  2973.     procedure CURSOR (CTYPE : CHARACTER) is
  2974. -- 
  2975. --      CURSOR programs the cursor type.
  2976. -- 
  2977. --      Inputs:  CTYPE = cursor type ('0'=blinking block, '1'=steady block,
  2978. --              '2'=blinking underline, '3'=steady underline)
  2979. --      Outputs:  None (cursor is set)
  2980. --      Side Effects:  None
  2981. -- 
  2982.     begin
  2983.         TEXT_IO.PUT (FO, ESCAPE); -- ESCAPE char 
  2984.         TEXT_IO.PUT (FO, "[3;");  -- set cursor 
  2985.         TEXT_IO.PUT (FO, CTYPE);  -- cursor type 
  2986.         TEXT_IO.PUT (FO, 'z');    -- done 
  2987.     end CURSOR;
  2988.  
  2989.  
  2990.     procedure FUNCTION_KEY (KEY : INTEGER; SHIFTED, XMIT : BOOLEAN) is
  2991. -- 
  2992. --      FUNCTION_KEY programs a function key with the string contained
  2993. --      in MESSAGE.
  2994. -- 
  2995. --      Inputs:  MESSAGE (global) = message to go into function key
  2996. --               KEY = number of function key (1 to 16)
  2997. --               SHIFTED = is function key shifted (T/F)?
  2998. --               XMIT = transmit string to computer (T/F)?
  2999. --      Outputs:  None (key is programmed)
  3000. --      Side Effects:  None
  3001. -- 
  3002.     begin
  3003.         TEXT_IO.PUT (FO, ESCAPE); -- send ESCAPE char 
  3004.         TEXT_IO.PUT (FO, '|');    -- programming function key 
  3005.         if (SHIFTED) then
  3006.             CHAROUT (CHARACTER'VAL (KEY + 16));            -- shifted key number
  3007.                                                            -- 
  3008.         else
  3009.             CHAROUT (CHARACTER'VAL (KEY));   -- unshifted key number 
  3010.         end if;
  3011.  
  3012.         TEXT_IO.PUT (FO, ';');    -- separator 
  3013.         if (XMIT) then
  3014.             TEXT_IO.PUT (FO, '1');            -- full duplex - send to computer
  3015.                                               -- only 
  3016.         else
  3017.             TEXT_IO.PUT (FO, '2');   -- local 
  3018.         end if;
  3019.  
  3020.         TEXT_IO.PUT (FO, ';');    -- separator 
  3021.         PRINT_MESSAGE;      -- send message 
  3022.         TEXT_IO.NEW_LINE (FO);
  3023.         UP;                          -- new line to end sequence 
  3024.     end FUNCTION_KEY;
  3025.  
  3026.  
  3027.     procedure KEY_CLICK (CLICK : BOOLEAN) is
  3028. -- 
  3029. --      KEY_CLICK turns on the key click if CLICK is TRUE or off the
  3030. --      key click if CLICK is FALSE.
  3031. -- 
  3032. --      Inputs:  CLICK = T if key click ON, F if key click OFF
  3033. --      Outputs:  None
  3034. --      Side Effects:  None (key click is affected)
  3035. -- 
  3036.     begin
  3037.         if (CLICK) then
  3038.             -- turn on key click 
  3039.             TEXT_IO.PUT (FO, ESCAPE);
  3040.             TEXT_IO.PUT_LINE (FO, "[6;0z");
  3041.             UP;
  3042.         else
  3043.             -- turn off key click 
  3044.             TEXT_IO.PUT (FO, ESCAPE);
  3045.             TEXT_IO.PUT_LINE (FO, "[6;1z");
  3046.             UP;
  3047.         end if;
  3048.     end KEY_CLICK;
  3049.  
  3050.  
  3051.     procedure LINE_TYPE (SELECTION : INTEGER) is
  3052. -- 
  3053. --      LINE_TYPE selects the 25th line as blank, status, or user
  3054. --      message.
  3055. -- 
  3056. --      Inputs:  SELECTION = type (0=blank, 1=status, 2=user message)
  3057. --      Outputs:  None
  3058. --      Side Effects:  None (line type is selected)
  3059. -- 
  3060.     begin
  3061.         TEXT_IO.PUT (FO, ESCAPE); -- ESCAPE char 
  3062.         TEXT_IO.PUT (FO, "[0;");  -- prefix 
  3063.         TEXT_IO.PUT (FO, CHARACTER'VAL (SELECTION + CHARACTER'POS ('0'))); -- digit char '0', '1', '2' 
  3064.         TEXT_IO.PUT_LINE (FO, "z");
  3065.         UP;
  3066.     end LINE_TYPE;
  3067.  
  3068.  
  3069.     procedure OTHER_TEXT is
  3070. -- 
  3071. --      OTHER_TEXT simply echoes the text which follows the O command
  3072. --      as-is (with escape sequence processing).
  3073. -- 
  3074. --      Inputs:  None
  3075. --      Outputs:  None
  3076. --      Side Effects:  None (text is sent to terminal)
  3077. -- 
  3078.  
  3079.         IDX : INTEGER;
  3080.         CHX : CHARACTER;
  3081.     begin
  3082.         IDX := 1;
  3083.  
  3084.         loop
  3085.             case TOUPPER (MESSAGE (IDX)) is
  3086.                 when CONTROL =>  -- output control char 
  3087.                     IDX := IDX + 1;
  3088.                     CHX := TOUPPER (MESSAGE (IDX));
  3089.                     CHX := CHARACTER'VAL
  3090.                              (CHARACTER'POS (CHX) - CHARACTER'POS ('@'));
  3091.                     TEXT_IO.PUT (FO, CHX);
  3092.  
  3093.                 when LITERAL =>  -- output literal char 
  3094.                     IDX := IDX + 1;
  3095.                     CHX := MESSAGE (IDX);
  3096.  
  3097.                     case TOUPPER (CHX) is
  3098.                         when LIT_DEL =>  TEXT_IO.PUT (FO, DELETE);
  3099.                         when LIT_ESC =>  TEXT_IO.PUT (FO, ESCAPE);
  3100.                         when others  =>  TEXT_IO.PUT (FO, CHX);
  3101.                     end case;
  3102.  
  3103.                 when others =>  TEXT_IO.PUT (FO, MESSAGE (IDX));
  3104.             end case;
  3105.  
  3106.             IDX := IDX + 1;
  3107.             exit when (MESSAGE (IDX) = NUL);
  3108.         end loop;
  3109.     end OTHER_TEXT;
  3110.  
  3111.     procedure PERSONAL_MESSAGE (MSG : INTEGER) is
  3112. -- 
  3113. --      PERSONAL_MESSAGE loads a personal message into the terminal.
  3114. --      It is the user's responsibility to ensure that the personal
  3115. --      message does not exceed 9 characters in length.
  3116. -- 
  3117. --      Inputs:  MESSAGE (global) = message to go into terminal
  3118. --               MSG = Personal Message Number (0 to 7)
  3119. --      Outputs:  None (message is programmed)
  3120. --      Side Effects:  None
  3121. -- 
  3122.     begin
  3123.         TEXT_IO.PUT (FO, ESCAPE);     -- send ESCAPE char 
  3124.         TEXT_IO.PUT (FO, '^');        -- personal message 
  3125.         CHAROUT (CHARACTER'VAL (MSG + 64)); -- PS number for message 
  3126.         TEXT_IO.PUT (FO, ';');        -- separator 
  3127.         PRINT_MESSAGE;          -- send message 
  3128.         TEXT_IO.NEW_LINE (FO);
  3129.         UP;                              -- new line to end sequence 
  3130.     end PERSONAL_MESSAGE;
  3131.  
  3132.     procedure PROGRAM_KEYS (PS : INTEGER) is
  3133. -- 
  3134. --      PROGRAM_KEYS programs a user-programmable key with a character
  3135. --      sequence.  It is the programmer's responsibility to ensure that
  3136. --      no more than the maximum number of bytes allowed for a particular
  3137. --      key are transmitted into it.
  3138. -- 
  3139. --      Inputs:  MESSAGE (global) = message to go into prog key
  3140. --               PS = Ps value which identifies key
  3141. --      Outputs:  None (key is programmed)
  3142. --      Side Effects:  None
  3143. -- 
  3144.     begin
  3145.         TEXT_IO.PUT (FO, ESCAPE); -- send ESCAPE char 
  3146.         TEXT_IO.PUT (FO, '\');    -- programming key 
  3147.         CHAROUT (CHARACTER'VAL (PS)); -- key identifier 
  3148.         TEXT_IO.PUT (FO, ';');    -- separator 
  3149.         PRINT_MESSAGE;      -- send message 
  3150.         TEXT_IO.NEW_LINE (FO);
  3151.         UP;                          -- new line to end sequence 
  3152.     end PROGRAM_KEYS;
  3153.  
  3154.  
  3155.     procedure USER_LINE (DOUBLE : BOOLEAN) is
  3156. -- 
  3157. --      USER_LINE programs the User's Message Line on the TVI 970 with
  3158. --      the string contained in MESSAGE.  If DOUBLE is TRUE, the message
  3159. --      appears as double-width.
  3160. -- 
  3161. --      Inputs:  MESSAGE (global) = string to be placed in message line
  3162. --               DOUBLE = is double-width text to be output (T/F)?
  3163. --      Outputs:  None (Message is stored)
  3164. --      Side Effects:  None
  3165. -- 
  3166.     begin
  3167.         TEXT_IO.PUT (FO, ESCAPE);  -- send ESCAPE char 
  3168.         TEXT_IO.PUT (FO, '^');     -- store User Line Message 
  3169.         if (DOUBLE) then
  3170.             -- enable double-width chars 
  3171.             TEXT_IO.PUT (FO, ' ');     -- space to position cursor 
  3172.             TEXT_IO.PUT (FO, ESCAPE);     -- goto double-width 
  3173.             TEXT_IO.PUT (FO, "[5;1z");
  3174.         end if;
  3175.  
  3176.         PRINT_MESSAGE;   -- output message 
  3177.         if (DOUBLE) then
  3178.             -- enable single-width chars 
  3179.             TEXT_IO.PUT (FO, ESCAPE);     -- goto single-width 
  3180.             TEXT_IO.PUT (FO, "[5;0z");
  3181.         end if;
  3182.  
  3183.         TEXT_IO.NEW_LINE (FO);
  3184.         UP;                       -- new line to end sequence 
  3185.     end USER_LINE;
  3186.  
  3187. ------------------------------------------------------------------
  3188. -- 
  3189. --      3. Command Processing Routines
  3190. --              PROCESS_ANSWER_BACK
  3191. --              PROCESS_CURSOR_TYPE
  3192. --              PROCESS_FCT_KEY
  3193. --              PROCESS_KEY_CLICK
  3194. --              PROCESS_LINE_TYPE
  3195. --              PROCESS_OTHER_TEXT
  3196. --              PROCESS_PERSONAL_MESSAGE
  3197. --              PROCESS_PROGRAM_KEYS (not yet used)
  3198. --              PROCESS_USER_LINE
  3199. -- 
  3200.  
  3201.     procedure PROCESS_ANSWER_BACK is
  3202. -- 
  3203. --      PROCESS_ANSWER_BACK reads in the answer back message
  3204. --      and programs the terminal with it.
  3205. -- 
  3206. --      Inputs:  None
  3207. --      Outputs:  None (message is programmed)
  3208. --      Side Effects:  None
  3209. -- 
  3210.     begin
  3211.         GET_MESSAGE;  -- input message 
  3212.         ANSWER_BACK;  -- send sequence 
  3213.     end PROCESS_ANSWER_BACK;
  3214.  
  3215.  
  3216.     procedure PROCESS_CURSOR_TYPE is
  3217. -- 
  3218. --      PROCESS_CURSOR_TYPE programs the type of cursor, as selected
  3219. --      from the file input.  Syntax:
  3220. -- 
  3221. --              Ccr
  3222. --      where:
  3223. --              c = B for Block (vs Underline) Cursor
  3224. --              r = S for Steady (vs Blinking) Cursor
  3225. -- 
  3226.  
  3227.         OPT        : CHARACTER;
  3228.         IDX, CTYPE : INTEGER;
  3229.     begin
  3230.         CTYPE := 2; -- cursor is blinking underline 
  3231.         GET_MESSAGE; -- read line into message buffer 
  3232.         IDX := 1;   -- 1st char 
  3233.         loop
  3234.             OPT := TOUPPER (MESSAGE (IDX));    -- get next char 
  3235.             IDX := IDX + 1;
  3236.  
  3237.             case OPT is
  3238.                 when 'B'    =>  CTYPE := CTYPE - 2; -- block cursor 
  3239.                 when 'S'    =>  CTYPE := CTYPE + 1; -- steady cursor 
  3240.                 when others =>  null;                 -- NULL statement 
  3241.             end case;
  3242.             -- case MESSAGE(IDX) 
  3243.             exit when OPT = NUL;
  3244.         end loop;
  3245.  
  3246.         CURSOR (CHARACTER'VAL (CTYPE + CHARACTER'POS ('0'))); -- set cursor 
  3247.     end PROCESS_CURSOR_TYPE;
  3248.  
  3249.  
  3250.     procedure PROCESS_FCT_KEY is
  3251. -- 
  3252. --      PROCESS_FCT_KEY programs a function key.  Syntax:
  3253. --              Fst n text
  3254. --      where:
  3255. --              s = S if fct key is shifted
  3256. --              t = L if local execution of key (term only)
  3257. --              n = function key number (1-16)
  3258. --              text = text of key
  3259. -- 
  3260. --      Inputs:  None
  3261. --      Outputs:  None
  3262. --      Side Effects:  None (Fct Key is programmed)
  3263. -- 
  3264.  
  3265.         SHIFTED, XMIT : BOOLEAN;
  3266.         OPT           : CHARACTER;
  3267.         KEY_NUMBER    : INTEGER;
  3268.     begin
  3269.         XMIT := TRUE;     -- default is xmit to computer 
  3270.         SHIFTED := FALSE; -- default is not shifted fct key 
  3271.         loop
  3272.             if TEXT_IO.END_OF_FILE (INFILE) then
  3273.                 STOP_ALL;
  3274.             else
  3275.                 TEXT_IO.GET (INFILE, OPT);          -- get next char 
  3276.             end if;
  3277.  
  3278.             OPT := TOUPPER (OPT);            -- capitalize 
  3279.             case OPT is
  3280.                 when 'L'    =>  XMIT := FALSE;  -- don't xmit to computer 
  3281.                 when 'S'    =>  SHIFTED := TRUE; -- shift fct key 
  3282.                 when others =>  null;              -- NULL statement 
  3283.             end case;
  3284.             -- case OPT 
  3285.             exit when (OPT = ' ');
  3286.         end loop;
  3287.  
  3288.         if TEXT_IO.END_OF_FILE (INFILE) then
  3289.             STOP_ALL;
  3290.         end if;
  3291.  
  3292.         INT_IO.GET (INFILE, KEY_NUMBER);  -- get number of key 
  3293.         if TEXT_IO.END_OF_FILE (INFILE) then
  3294.             STOP_ALL;
  3295.         end if;
  3296.  
  3297.         TEXT_IO.GET (INFILE, OPT);         -- flush following char 
  3298.         GET_MESSAGE;                -- input text 
  3299.         FUNCTION_KEY (KEY_NUMBER, SHIFTED, XMIT);
  3300.     end PROCESS_FCT_KEY;
  3301.  
  3302.  
  3303.     procedure PROCESS_KEY_CLICK is
  3304. -- 
  3305. --      PROCESS_KEY_CLICK turns on and off the key click.  Syntax:
  3306. --              Kk
  3307. --      where:
  3308. --              k = Y if key click on (otherwise off)
  3309. -- 
  3310. --      Inputs:  None
  3311. --      Outputs:  None
  3312. --      Side Effects:  None (key click is affected)
  3313. -- 
  3314.  
  3315.         CLICK : BOOLEAN;
  3316.     begin
  3317.         GET_MESSAGE;
  3318.  
  3319.         if (TOUPPER (MESSAGE (1)) = 'Y') then
  3320.             CLICK := TRUE;
  3321.         else
  3322.             CLICK := FALSE;
  3323.         end if;
  3324.  
  3325.         KEY_CLICK (CLICK);
  3326.     end PROCESS_KEY_CLICK;
  3327.  
  3328.  
  3329.     procedure PROCESS_LINE_TYPE is
  3330. -- 
  3331. --      PROCESS_LINE_TYPE selects the type of line displayed at the
  3332. --      25th line.  Syntax:
  3333. --              Ll
  3334. --      where:
  3335. --              l = U if user, S if status (default is blank)
  3336. -- 
  3337. --      Inputs:  None
  3338. --      Outputs:  None
  3339. --      Side Effects:  None (line is set)
  3340. -- 
  3341.  
  3342.         LTYPE : INTEGER;
  3343.     begin
  3344.         GET_MESSAGE; -- input text 
  3345.         case TOUPPER (MESSAGE (1)) is
  3346.             when 'U'    =>  LTYPE := 2;
  3347.             when 'S'    =>  LTYPE := 1;
  3348.             when others =>  LTYPE := 0;
  3349.         end case;
  3350.  
  3351.         LINE_TYPE (LTYPE); -- set line type 
  3352.     end PROCESS_LINE_TYPE;
  3353.  
  3354.  
  3355.     procedure PROCESS_OTHER_TEXT is
  3356. -- 
  3357. --      PROCESS_OTHER_TEXT sends the text following the command
  3358. --      to the terminal with escape processing.  Syntax:
  3359. --              O<text>
  3360. -- 
  3361. --      Inputs:  None
  3362. --      Outputs:  None
  3363. --      Side Effects:  None (text is sent to terminal)
  3364. -- 
  3365.     begin
  3366.         GET_MESSAGE; -- input text 
  3367.         OTHER_TEXT;  -- output text 
  3368.     end PROCESS_OTHER_TEXT;
  3369.  
  3370.  
  3371.     procedure PROCESS_PERSONAL_MESSAGE is
  3372. -- 
  3373. --      PROCESS_PERSONAL_MESSAGE programs one of the personal messages
  3374. --      with a new character string.  The user is responsible for
  3375. --      ensuring that the string is not too long for the message's buffer.
  3376. --      Syntax:
  3377. --              M n text
  3378. --      where:
  3379. --              n = Message Number (0 to 7)
  3380. --              text = text for message
  3381. -- 
  3382. --      Inputs:  None
  3383. --      Outputs:  None
  3384. --      Side Effects:  None (Message is programmed)
  3385. -- 
  3386.  
  3387.         OPT        : CHARACTER;
  3388.         MSG_NUMBER : INTEGER;
  3389.     begin
  3390.         if TEXT_IO.END_OF_FILE (INFILE) then
  3391.             STOP_ALL;
  3392.         end if;
  3393.  
  3394.         INT_IO.GET (INFILE, MSG_NUMBER);  -- get number of message 
  3395.         if TEXT_IO.END_OF_FILE (INFILE) then
  3396.             STOP_ALL;
  3397.         end if;
  3398.  
  3399.         TEXT_IO.GET (INFILE, OPT);         -- flush following char 
  3400.         GET_MESSAGE;                -- input text 
  3401.         PERSONAL_MESSAGE (MSG_NUMBER);
  3402.     end PROCESS_PERSONAL_MESSAGE;
  3403.  
  3404.  
  3405.     procedure PROCESS_PROGRAM_KEYS is
  3406. -- 
  3407. --      PROCESS_PROGRAM_KEYS programs one of the programmable keys
  3408. --      with a new character string.  The user is responsible for
  3409. --      ensuring that the string is not too long for the key's buffer.
  3410. --      Syntax:
  3411. --              P n text
  3412. --      where:
  3413. --              n = Ps value of key (0 to 62)
  3414. --              text = text for key
  3415. -- 
  3416. --      Inputs:  None
  3417. --      Outputs:  None
  3418. --      Side Effects:  None (Key is programmed)
  3419. -- 
  3420.  
  3421.         OPT        : CHARACTER;
  3422.         KEY_NUMBER : INTEGER;
  3423.     begin
  3424.         if TEXT_IO.END_OF_FILE (INFILE) then
  3425.             STOP_ALL;
  3426.         end if;
  3427.  
  3428.         INT_IO.GET (INFILE, KEY_NUMBER);  -- get number of key 
  3429.         if TEXT_IO.END_OF_FILE (INFILE) then
  3430.             STOP_ALL;
  3431.         end if;
  3432.  
  3433.         TEXT_IO.GET (INFILE, OPT);         -- flush following char 
  3434.         GET_MESSAGE;                -- input text 
  3435.         PROGRAM_KEYS (KEY_NUMBER);
  3436.     end PROCESS_PROGRAM_KEYS;
  3437.  
  3438.  
  3439.     procedure PROCESS_USER_LINE is
  3440. -- 
  3441. --      PROCESS_USER_LINE inputs the user line and programs the terminal
  3442. --      with it.  Syntax:
  3443. --              U<text>
  3444. -- 
  3445. --      Inputs:  None
  3446. --      Outputs:  None
  3447. --      Side Effects:  MESSAGE (global) is changed
  3448. -- 
  3449.     begin
  3450.         GET_MESSAGE; -- input user line 
  3451.         USER_LINE (FALSE); -- program line with normal width chars 
  3452.     end PROCESS_USER_LINE;
  3453.  
  3454.  
  3455. ------------------------------------------------------------------
  3456. -- 4. Mainline 
  3457.  
  3458. begin
  3459.     -- Mainline  
  3460.     TEXT_IO.PUT_LINE ("P970 Version " & VERSION);
  3461.     TEXT_IO.PUT (PROMPT);
  3462.     TEXT_IO.GET_LINE (FNAME, FNAME_LENGTH);
  3463. -- open command file 
  3464.     TEXT_IO.OPEN (INFILE, TEXT_IO.IN_FILE, FNAME (1 .. FNAME_LENGTH));
  3465.     TEXT_IO.CREATE (FO, TEXT_IO.OUT_FILE, SYS_OUTPUT);   -- open output file 
  3466.  
  3467.     loop
  3468.         if TEXT_IO.END_OF_FILE (INFILE) then
  3469.             CMD := 'E';
  3470.         else
  3471.             TEXT_IO.GET (INFILE, CMD);            -- get command letter 
  3472.         end if;
  3473.  
  3474.         CMD := TOUPPER (CMD);              -- convert to upper case 
  3475.         case CMD is
  3476.             when ' ' =>  GET_MESSAGE;
  3477.  
  3478.             when 'A' =>  PROCESS_ANSWER_BACK;
  3479.  
  3480.             when 'C' =>  PROCESS_CURSOR_TYPE;
  3481.  
  3482.             when 'E' =>  CMD := 'Z';
  3483.  
  3484.             when 'F' =>  PROCESS_FCT_KEY;
  3485.  
  3486.             when 'K' =>  PROCESS_KEY_CLICK;
  3487.  
  3488.             when 'L' =>  PROCESS_LINE_TYPE;
  3489.  
  3490. -- Personal Messages Not Implemented because of error in manual 
  3491. --                      'M' => process_personal_message; 
  3492.  
  3493.             when 'O' =>  PROCESS_OTHER_TEXT;
  3494.  
  3495.             when 'P' =>  PROCESS_PROGRAM_KEYS;
  3496.  
  3497.             when 'U' =>  PROCESS_USER_LINE;
  3498.  
  3499.             when 'Z' =>  CMD := 'Z';
  3500.  
  3501.             when ';' =>  GET_MESSAGE;
  3502.  
  3503.             when others => 
  3504.                 TEXT_IO.PUT ("Invalid Command: ");
  3505.                 TEXT_IO.PUT (CMD);
  3506.                 TEXT_IO.NEW_LINE;
  3507.                 GET_MESSAGE;
  3508.         end case;
  3509.  
  3510.         exit when (CMD = 'Z');
  3511.     end loop;
  3512.  
  3513.     exception
  3514.         when HALT =>
  3515.             null;
  3516. end PROG970;