home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / JSAGE / ZSUS / WORDPACK / MACRODAT.DOC < prev    next >
Text File  |  2000-06-30  |  12KB  |  273 lines

  1. THE DATE AT A TOUCH OF A FUNCTION KEY         April 9, 1989
  2. by Rick Charnes                                   ^   ^
  3.                                                 Like this
  4.  
  5.  
  6. MACRODAT is a nifty way I've put together for my ZSDOS/ZDDOS 
  7. system to have the date appear at the touch of a macro key while 
  8. in VDE.
  9.  
  10. REQUIRED:  
  11. --------
  12. ZEX403    NZEX-D will NOT work here.  You can continue using 
  13.           NZEX-D as your default ZEX; you will simply be using 
  14.           ZEX403 for this application.
  15.  
  16.  
  17. MACRODAT requires that, after reading your standalone STARTUP.COM 
  18. (or whatever name is used in your system), your ZCPR3 startup 
  19. procedure then access both an ARUNZ alias and a ZEX script.  If 
  20. your startup procedure doesn't now access a ZEX script at cold 
  21. boot, adding one in certainly makes for a little longer startup, 
  22. but you may judge for yourself whether it is worth it.  
  23. Considering that my startup procedure provides not only for this 
  24. but also displays to me -- in beautiful reverse video graphics -- 
  25. the time I last turned my computer on, I consider it time well 
  26. spent.
  27.  
  28. I'd like to show and tell my entire startup procedure here.  I 
  29. find it so useful and am so proud of it that I'm going to 
  30. describe the whole thing.  I'll get to the date-on-the-macro-key 
  31. part fairly quickly.
  32.  
  33. In everything that follows, you will often see the letter 'l' as 
  34. a standalone command.  As an extremely frequent ARUNZ user I am 
  35. always cognizant of when I'm pushing up against the ZCPR3 command 
  36. line buffer's 200-character limit.  As flow control is an 
  37. essential part of alias programming, years ago I permanently 
  38. renamed the ELSE in my FCP to L.  If I use it three times in an 
  39. alias that's 9 characters I've saved, often meaning the 
  40. difference between a successful alias and the dreaded 'OVFL' 
  41. message.
  42.  
  43. Here we go.
  44.  
  45. My standalone STARTUP.COM alias loads LAP.COM (containing all my 
  46. environment system segments) and my hard disk, and then, extended 
  47. command processing now being available, passes control to an 
  48. ARUNZ alias named START, which is as follows:
  49.  
  50. START    
  51. if gt $dh 17
  52. t m eve
  53. l
  54. if gt $dh 11
  55. t m aft
  56. l
  57. if gt $dh 05
  58. t m morn
  59. l
  60. t m wee
  61. zif
  62. dly /p4
  63. reg s2 $dd q
  64. go s3 $dc q
  65. go s7 $dm q
  66. go s8 $dd q
  67. go s9 $dy q
  68. laston
  69.  
  70. As explained in my TIMOFDAY.LBR, 'EVE, 'AFT', 'MORN' and 'WEE' 
  71. are all text files displaying box-graphics with messages to the 
  72. effect of "GOOD EVENING, SIR!", 'GOOD AFTERNOON!', 'GOOD 
  73. MORNING!', and 'STAYING UP TILL THE WEE HOURS AGAIN, ARE YOU?" 
  74. respectively.  You can see how IF.COM and flow control will 
  75. display one or the other of these files depending on the time of 
  76. day.  T.COM is a version of the ancient TYPEL.COM patched to NOT 
  77. translate control characters, and it types files out of my 
  78. 'message library' M.LBR which contains dozens of various 
  79. 'status-reporting' files such as the four above.  DLY.COM is my 
  80. version of SAK.COM patched to *not* display its "Resuming..." 
  81. message after the four seconds of sleeping are up.
  82.  
  83. Then we (quietly) set register 2 to today's date and register 3 
  84. to the current hour, in civil form.  We'll be using these later 
  85. for a couple of purposes.  Then, so we can use Naj Najarian's 
  86. great method for inserting the date into dBASE as explained in 
  87. his DBPATCHS.DOC, we put today's month, date and year into three 
  88. consecutive registers.  Since we're now using LSH, and not EASE 
  89. which eats up registers 7, 8 and 9, these three serve our 
  90. purposes perfectly.  Finally we go to the next alias, LASTON, 
  91. which was written up in my column in TCJ #37.  Its primary 
  92. purpose is to read and write the shell variable used to display 
  93. the last time we turned our computer on.  Since I wrote the 
  94. article I have modified and made much more flexible the method by 
  95. which we do this (see my DAY10.LBR.)
  96.  
  97. LASTON
  98. q s
  99. rs laston %startdat $$|shf %$dm$dy
  100. rs reg s25 %pcph$dm$dy q$$|reg s26 %pcpm$dm$dy q$$| <<
  101.    ze4 startup %$dd %$dm$dy $rf02 $dy $rf03:$dn $da
  102.  
  103. RESOLVE loads LASTON.COM, which displays the shell variable 
  104. STARTDAT containing the time we last turned on our computer.  
  105. Then the '$$|' acts as RESOLVE's substitute command-separator (be 
  106. sure to keep the space character immediately after the 
  107. '%STARTDAT') and, assuming the month of March, 1989 SHFILE sets 
  108. the current variable file to WEDNESDA.VAR.  See my DAY10.LBR for 
  109. more on this.
  110.  
  111. The first part of the next RESOLVE line is for my PCPMX+ script.  
  112. The variables named 'PCPHmmyy' and 'PCPMmmyy', where mm = today's 
  113. month and yy = today's year, hold the number of hours and minutes 
  114. respectively I have used PC Pursuit so far that month.  I set 
  115. register 25 to the value held by the string variable '%PCPHmmyy' and 
  116. register 26 to the value held by '%PCPMmmyy'.  
  117.  
  118. Still using RESOLVE's multiple command separator '$|' which 
  119. translates into a ';', we come to the crucial part, our ZEX 
  120. script.  First we need to understand the rather complex commad 
  121. line we are giving ZEX here.  We've got two programs that will 
  122. resolve variables here, ARUNZ and then RESOLVE.  After ARUNZ does 
  123. its work on that ZE4 line, assuming a date of April 9, 1989 and 
  124. a time of 7:30 am, and remembering that register 2 holds the 
  125. current date and 3 the hour, we get:
  126.  
  127. ze4 startup %$dd %$dm$dy $rf02 $dy $rf03:$dn $da
  128.              |       |     |     |      |      |                   
  129. ze4 startup %09   %0489    9    89    7:30    am
  130.  
  131. The reason we previously put the date and hour into registers 2 
  132. and 3 respectively might be a little hard to fathom.  You might 
  133. ask here: why not simply use the '$dd' and '$dh' ARUNZ symbols 
  134. here instead of '$rf02' and $rf03'?
  135.  
  136. Here's why.  '$dd' and '$dh' always return their values as two 
  137. digits, even if the value is only a single digit, as they are 
  138. here.  The beauty of the $RFnn symbol (see the ARUNZ 
  139. documentation) is that it generates a 'floating decimal' result 
  140. -- if there are 2 digits you get 2, and if there is only 1 you 
  141. get only 1.  This greatly adds to the readability and 
  142. attractiveness of our result; seeing that today's date is 
  143.  
  144.                        April 9 at 7:30 am
  145.  
  146. gives us a much nicer feeling than 
  147.  
  148.                       April 09 at 07:30 am
  149.  
  150. which seems stilted and impersonal.  (Whaddaya expect, it's a 
  151. computer.)  I think this little extra effort is well worth it.
  152.  
  153. Ok, now let's see what RESOLVE does with what ARUNZ gave us:
  154.  
  155. ze4   startup      %09      %0489     9      89     7:30     am
  156.  
  157. ze4   startup    sunday     april     9      89     7:30     am
  158.  
  159. The '%09' and '%0489' variables are each defined in our SH.VAR 
  160. file as 'sunday' and 'april' respectively.  I explained most of 
  161. this in my TCJ article.
  162.  
  163. So this is the command line passed to ZEX, which brings us to...
  164.  
  165. DATE-ON-A-MACRO-KEY
  166. -------------------
  167.  
  168. ...the relevant part.  I have renamed Joe Wright's ZEX403, which 
  169. is necessary here, to ZE4.  The following is the ZEX script named 
  170. STARTUP.ZEX, with comments to the right.
  171.  
  172. ^<^[=0:* Loading system segments *^|^>  ; Displays message, using terminal
  173.                                         ;  cursor positioning codes
  174. ^.era date                              ; Turns console display off
  175.                                         ;  and erases file 'DATE'
  176. dprog                                   ; Initializes my printer
  177. ^%vde date                              ; Opens up file 'DATE' and
  178.                                         ;  and prepares to send ZEX
  179.                                         ;  command stream into it
  180. $2 $3, 19$4^qs^d^kx             
  181.  
  182. COMMENT: The above is the crucial line.  After opening up the file DATE, we 
  183. send (remembering our ZEX parameters as above) 'APRIL 9, 1989' as input 
  184. into the file.  Easy!  However, since all command-processor input such as 
  185. parameters are always upper case, our job isn't over yet.  We want it to 
  186. look nice, so we'll convert all letters of the name of the month except the 
  187. first to lower case.  We use VDE's CTL-^ feature which toggles case.  With 
  188. CTL-QS we return to the beginning of the line we just created which places 
  189. the cursor on top of the first character, here 'A.' Then with CTL-D we move 
  190. to the second.  Then follows a series of exactly 8 CTL-^ characters (enter 
  191. them with VDE into your STARTUP.ZEX by first holding down CTL-P, then the 
  192. '^'.  We allow for the possibility of the longest-named month, 
  193. S-E-P-T-E-M-B-E-R, and convert all letters in it after the initial 'S' to 
  194. lower case.  For shorter-named months we'll just have wasted a few extra 
  195. CTL-^'s -- no big deal.
  196.  
  197. Then with CTL-KX we save the file.  We've just created a file named 'DATE' 
  198. that consists of the exact string 'April 9, 1989'.
  199.  
  200. The rest of my STARTUP.ZEX is not germane to MACRODAT, but...
  201.  
  202. shellini                                ; Initialize shell stack.
  203. shfile sh                               ; Return SH.VAR to default.
  204. ^.^<^[=4>^[G2Still loading...^[G0^>     ; Might be wondering what's 
  205.                                         ;  going on, so turn console display 
  206.                                         ;  ON and display 2nd message!
  207.                                         ;  ESC-G2 turns blink mode on for
  208.                                         ;  my Qume102, ESC-G0 turns it off.
  209. ^.shvar startdat $1, $2 $3, 19$4  $5 $6 ; All this is explained in my 
  210.                                         ;  column in TCJ #37.  Turns display
  211.                                         ;  OFF, then writes variable to VAR file
  212.                                         ;  to display last time powered-up.
  213. lsh                                     ; Bye-bye, EASE!
  214. zerr                                    ; Error handler.
  215. ^.^<^[=4 ^[T^[=4EDone.^[.^>             ; Console display back ON, say we're
  216.                                         ;  done.
  217.  
  218.                                     * * *
  219.  
  220. Now we have our file named DATE, residing on A0:.  All that 
  221. remains is to write a simple VDE macro.  Using Fred Haines' 
  222. wonderful VDECOM or VDE's inbuilt macro editor, we simply enter:
  223.  
  224.                         q^KRA0:DATE^M^QD
  225.  
  226. The initial 'q' turns MACRO QUIET mode ON, which is very 
  227. important.  Then CTL-KR prepares to read in a file.  We respond 
  228. 'A0:DATE' and ^M (carriage return) which reads in our 
  229. just-created file.  Since after a file is read in with the ^KR 
  230. command the cursor is placed at the *begining* of the file, we 
  231. simply add a 'CTL-QD' to place the cursor AFTER the file we've 
  232. just read, which just happens to be our date string!  And we're 
  233. done.
  234.  
  235. Quite nifty, I think.
  236.  
  237.                               * * *
  238.  
  239. MACRODAT also (sort of) works with WS or NW, but we're really 
  240. taking advantage of VDE's 'QUIET' mode for macros here and since 
  241. WS4's 'shorthand' feature (nor other key redefiners with any 
  242. other WS or NW) has nothing comparable, on these other programs 
  243. it's much more sluggish, inelegant and doesn't look really like a 
  244. macro like it does with VDE.  Since 95% of my writing is with 
  245. VDE, though, it doesn't bother me a bit.
  246.  
  247. I used to not go to all this 'trouble' -- floating decimal 
  248. registers, ZEX scripts, case toggle commands.   I used to use Rob 
  249. Friefeld's wonderful ZSDOS-supporting NT42 in a similar way to 
  250. write a file consisting of nothing but the date and time.  But 
  251. here's what NT42's output looks like:
  252.  
  253.                       09 Apr 1989  20:45:04
  254.  
  255. If you're writing a letter to your girlfriend, you don't want to 
  256. start it off '09 Apr 1989'.  What's she going to think, that a 
  257. computer wrote your letter?  You can erase the '20:45:04' if you 
  258. want, but 'Apr' for 'April' just doesn't do.  And let's face it, 
  259. we Americans simply will never get used to European format and 
  260. that's our prerogative.  Using ZEX and ARUNZ and going through 
  261. all that 'trouble,' which, let's face it, for us computer nerds 
  262. is no trouble at all, is all the joy in the world.
  263.  
  264. Have fun with MACRODAT.  You can, of course, excerpt from what I 
  265. have described as suits your needs.
  266.  
  267.  
  268. Rick Charnes, San Francisco, April 9, 1989
  269.                                |   |    |
  270.                          Works every time...
  271.  
  272. Human voice: (415) 826-9448
  273.