home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / utils / sysutl / egutil53.lbr / GSUB.DZC / GSUB.DOC
Encoding:
Text File  |  1988-07-12  |  15.5 KB  |  388 lines

  1. ;;07-10-85
  2.  
  3.                           GSUB.DOC v2.0
  4.                            (09/20/86)
  5.  
  6. Eric Gans
  7. French Dep't UCLA
  8. Los Angeles, CA 90024
  9.  
  10.                            Version 2.0
  11.  
  12. Allows  default  parameters in SUB file,  "quiet" mode  (suppress 
  13. messages/filenames).   GOTOG now accepts filenames (GOTOG WS)  as 
  14. well as command numbers.   Fixed IFG bug that disallowed messages 
  15. after IFG or ELSEG.  Thanks to James Quillin and Ernest Helliwell 
  16. for their suggestions.
  17.  
  18. The (formerly separate) IFG.DOC is now included in this file.
  19.  
  20. Version 1.5 (4/86)
  21. Allows lower case internal input in direct mode with "%".  Thanks 
  22. to  L.  Patrick  Purtell  for pointing  out  that  v1.4  wouldn't 
  23. implement PerfectCalc's ^Xm.. command (^XM won't do it).
  24.  
  25.  
  26.                               *****
  27.  
  28.  GSUB  is  a  SUBMIT substitute that puts its command  buffer  in 
  29. memory instead of in a $$$.SUB disk file. It allows:
  30.  
  31. - internal program input separate from CCP input 
  32. - IF-ELSE-GOTO structures including counted loops
  33. - chaining of batch files (v1.1+)
  34. - run from command line or SUB file
  35. - unlimited command space (v1.2)
  36. - output messages to console from SUB file (v1.4)
  37. - variables ($1 - $9) permitting null values and defaults (2.0)
  38. - control characters, lower case (1.5)
  39. - wait for console input
  40. - comments
  41. - "quiet" mode (2.0)
  42. - reentrant: can chain with itself 
  43.  
  44.  
  45. GSUB  is  smaller  &  faster than EX (or  any  other  CP/M  batch 
  46. program).  It  only  does  a long CCP return (for  chaining  with 
  47. SUBMIT or to reset drives) on request.  Its command buffer has no 
  48. size limit; only what is filled is placed in memory. Like SUBMIT, 
  49. GSUB  can  be  aborted by typing a character  before  it  regains 
  50. control. 
  51.  
  52.                            Why not EX?
  53.  
  54. EX  can't distinguish between console input within a program  and 
  55. input  to the CCP.  Thus it can't run a SUB file that contains  a 
  56. series  of programs one of which allows console  input;  it  just 
  57. reads the rest of the SUB file into the program.  For example,  I 
  58. use a little file Z.SUB for writing assembly language programs: 
  59.  
  60.           ws $1.azm  
  61.           z80mr $1.bbz  
  62.           mload $1
  63.  
  64. EX can't handle this;  as soon as it gets into Wordstar it writes 
  65. the other two lines into my source file instead of waiting to get 
  66. back to the console. GSUB solves this problem while allowing full 
  67. control  of the batch process with IF-ELSE-GOTO and counted  loop 
  68. structures.
  69.  
  70. But...
  71.  
  72. Although GSUB can handle any "reasonable" internal program input, 
  73. it  can't pass commands to a few programs (like VDE) that use the 
  74. BIOS  CONSTAT  function to check for a keypress  before  allowing 
  75. input.   To  disable this function would be asking  for  trouble.  
  76. (Thanks to Rick Charnes for revealing this problem.)
  77.  
  78. Command syntax:
  79.  
  80. (1) Command line: to run GSUB in direct mode (without a SUB file) 
  81. you  enter  the  command line as follows  (CP/M  will  process  a 
  82. maximum of 127 characters):
  83.  
  84. gsub =[?;]cmd1[;{file-internal commands}][cmd2;[~]..[;&]
  85.  
  86. CCP  commands (except the last in line) must be followed by  ";".
  87. These follow standard syntax.
  88.  
  89. ?  entered as a separate command (not necessarily first) will put 
  90. GSUB in quiet mode.   CCP commands (e.g.,  COM filenames, DIR...) 
  91. will not be displayed.  In SUBfile mode, messages <...> will also 
  92. be suppressed.
  93.  
  94. File-internal  commands must be within "{...}".  The closing  "}" 
  95. need not be followed by a ";", although it makes things clearer, 
  96.  
  97. $<ch>  will  take  <ch> as a literal (i.e.,  to use  "{"  in  the 
  98. command line, write "${")
  99.  
  100. ~  entered  at the beginning of a command will produce  an  input 
  101. request;  this is better done in SUBfile mode where you can enter 
  102. a prompt message.
  103.  
  104. ^<ch> will produce a control character
  105.  
  106. "&"  entered  as a separate command at the end of the  line  will 
  107. produce  a  "long" CCP return that allows chaining  with  SUBMIT.  
  108. Use  this  switch if you want to use GSUB to run a  program  like 
  109. SUBMIT  that creates $$$.SUB disk files,  or if  your  operations 
  110. require a disk reset after Warm Boots (the default avoids this).
  111.  
  112. Internal Commands (within {...})
  113.  
  114. | = carriage return (0Dh = ^m)
  115. ~ waits for a character input
  116.  
  117. %<ch> (<ch> must be a letter) used in direct mode will produce  a 
  118. lower-case  letter.   Since  the CCP folds all lc letters to  uc, 
  119. this  is the only way of getting lower-case letters that  certain 
  120. program  commands  (e.g.,   PerfectCalc  ^Xm...)  require.   This 
  121. command is not required in file mode,  since you can simply enter 
  122. the  lower-case letter in the file,  nor is it necessary for  CCP 
  123. commands which will be "folded" anyway.
  124.  
  125. Examples: gsub =ws;{nblurk.azm^m}era *.bak   will enter WS & open 
  126. the  non-document  file  blurk.azm,  then on exit erase  the  BAK 
  127. file(s)
  128.           
  129. gsub =ddt;{dd200|lea00~s100|42|4c|55|52|4b|.|^c}save 1 blurk
  130.  
  131. will  enter ddt,  dump d200-,  write out the command "lea00"  and 
  132. wait for you to type a key (e.g., a CR), then display the byte at 
  133. 100H and enter five characters and a "." to end, exit with ^C and 
  134. save  the result.   Note that except for the wait for input,  the 
  135. second  example  might  have  been  accomplished  (several  times 
  136. slower)  with SUBMIT and XSUB,  but not the first,  since "n"  in 
  137. Wordstar  does not use CPM function #10 and is thus  inaccessible 
  138. to XSUB.  EX could handle the "n" OK,  but would then proceed  to 
  139. write "era *.bak" into the first line of BLURK.AZM.
  140.  
  141.  
  142. (2) File input:
  143.  
  144. Variables:  as in normal SUB files,  variables should be numbered 
  145. consecutively  from  $1  to $9.  You may enter "@" alone  in  the 
  146. command  line  to  signify a null variable,  or "@@" to  use  the 
  147. default value.
  148.  
  149. Default  values:  (v2.0)  You may enter a default  value  in  the 
  150. subfile  using the format $n^default^.   Thus $3^ws urk^ will set 
  151. WS URK as the default command if no third variable is given.   NB 
  152. that you still have the choice of entering a null value (using  @ 
  153. instead of @@ on the command line).
  154.  
  155. "&" entered separately at the end of the command line will switch 
  156. on the long CCP return as above.
  157.  
  158. ? entered separately on the command line will produce quiet mode; 
  159. CCP commands and messages (<...>) will be suppressed.
  160.  
  161. As  with  SUBMIT,  each CCP command must be followed by  a  CRLF. 
  162. Internal commands may include CRLF's also; usually a CR alone (|) 
  163. suffices.  The  internal command line,  if any,  must end with  a 
  164. CRLF after the closing "}".
  165.  
  166. Messages to be displayed to the console during operation  (either 
  167. in  CCP or file-internal mode) are placed between  "<...>".  GSUB 
  168. will check for closed brackets of both {} and <>; you are advised 
  169. not  to try structures like "{ ...  < ...  } ...  >" (GSUB  would 
  170. interpret the "}" as display text).
  171.  
  172. NB  - Within the display brackets,  the character "|"  is  inter-
  173. preted  as a CRLF.   To kill the CRLF at the end of a line (e.g., 
  174. if  the line you want to display contains control characters that 
  175. won't actually print but will set video controls), enter "\" just 
  176. before the CR.  The message will not end with a CRLF unless it is 
  177. within the brackets:
  178. <Hi there!>
  179. zap
  180. will run ZAP.COM OK, but will display as "Hi there!ZAP" on screen.
  181.  
  182.  
  183. Comment  lines  beginning  with  ";" will not be  copied  to  the 
  184. command  buffer.   You may also add comments after the end of the 
  185. internal command line.
  186.  
  187. $<ch>  will  produce  a  literal of <ch>  for  anything  but  the 
  188. variables $1-$9.
  189.  
  190. Otherwise, the $, ^, | and ~ symbols function as above.
  191.  
  192. Examples:
  193.  
  194. (1)
  195. ws
  196. {nblurk.azm|}
  197. era *.bak
  198.  
  199. (2)
  200. <Program to save an important concept on disk.|||>
  201. ddt
  202. {<This really works!!!|>
  203.  .... } (as above)
  204. save 1 blurk
  205.  
  206. Another  way of entering a CR into the internal input is to go to 
  207. the  next  line;  the  program kills the LF's  that  are  usually 
  208. misinterpreted  by  word-processors &  other  programs  (Wordstar 
  209. thinks you want to set the help level with ^J):
  210.  
  211. (3)
  212. ;for the literary
  213. ws charlott.let
  214. {Liebchen, I can't live without you.
  215. Death is my only recourse.
  216. ;don't believe a word - The Editor
  217.  - Werther
  218. ^kx}  ;pretty hot stuff?
  219.  
  220. To  output  control characters etc.  to the screen  in  immediate 
  221. mode, enter them as external commands (NOT within {...}):
  222.  
  223. gsub =^g^z^[B0^[=00BLURK!^[C0^m
  224.  
  225. will sound the bell (^g),  then (on an ADM 3A) blank the  screen, 
  226. set  inverse  video,  go sixteen lines down and  sixteen  across, 
  227. print BLURK!, then turn off inverse video and do a CR. (You can't 
  228. use | here.)
  229.  
  230.  
  231. SELF-CHAINING
  232.  
  233. GSUB  can chain with itself an indefinite number of times.   This 
  234. feature  can be useful with SUB files;  if you want to run a  SUB 
  235. file along with some other programs you can enter:
  236.      gsub =gsub zlurk;zap;blurk;gsub zlonk... etc.  Even
  237.      gsub =gsub gsub zlurk;...  is possible, although  the second 
  238. gsub can't do much since the first semicolon will return  control 
  239. to gsub No. 1.
  240.  
  241. CHAINING WITH SUBMIT
  242.  
  243. If  "&" is entered at the end of the command line in either  file 
  244. or immediate mode,  GSUB returns control after Warm Boots to  the 
  245. start  of the CCP and thus allows the accessing of $$$.SUB  files 
  246. from  within  the program.  This allows you to include  calls  to 
  247. SUBMIT  (or  other  disk-based batch utilities  like  my  program 
  248. OFFRUN)  within  a GSUB command line or SUB file.  Thus  you  can 
  249. enter:  gsub =submit blurk urk1 urk2;submit zlonk urk3 ur4 urk5;& 
  250. (NB  the "@"=null feature won't work here) and both blurk.sub and 
  251. zlonk.sub  will  be  submitted.  Or you can put  this  series  in 
  252. YECCH.SUB  and enter:  gsub yecch urk1 urk2 @ urk4..  &  In  this 
  253. case, remember not to use SUBMIT with YECCH.SUB! 
  254.  
  255. Technical notes:
  256.  
  257. GSUB  distinguishes  between  CCP and internal program  input  by 
  258. trapping  BDOS calls to CP/M function 10.   The location  of  the 
  259. "late" CCP return is determined from the stack.  GSUB also checks 
  260. for  changes in the BDOS jump address (at 0006) made by  programs 
  261. that  want  to keep themselves resident in  memory,  and  locates 
  262. itself  just under the resident program.  CP/M function 6 (direct 
  263. console  I/O)  is handled by trapping calls  to  the  BDOS.  When 
  264. internal program input is finished, GSUB puts back the BIOS CONIN 
  265. address  not  only in the BIOS jump table but in its own  console 
  266. input  routine in order to work with programs (like MBasic)  that 
  267. skip  past the jump table.  GSUB 2.0 should be usable on any  CPM 
  268. system under any circumstances.  
  269.  
  270. Additional notes:  GSUB will work with "anything" only so long as 
  271. the "true" address of the BDOS is not required.   So don't try it 
  272. with programs like SYSGEN or MOVCPM.   If you use a SMARTKEY like 
  273. program  within GSUB,  it will disappear when GSUB does;  if  you 
  274. want it to stay in memory,  load it first, or use SUBMIT, OFFRUN, 
  275. CMDLN etc.
  276.  
  277.                               *****
  278.  
  279.                          IFG/ELSEG/GOTOG
  280.  
  281. GOTOG  now  accepts  command  names as  well  as  numbers.   This  
  282. version    of  IFG/ELSEG/GOTOG/ENDIFG  also  fixes  a  bug   that 
  283. mishandled GSUB screen messages (enclosed in <>).   It should now 
  284. be   possible  to  use  messages  after  IFG  or  ELSEG   without 
  285. difficulty.   Since  IFG  outputs its own message,  to  put  your 
  286. message  on a new line,  precede it with a  CR,  thus:  <|message 
  287. after IFG|>.
  288.  
  289. The  new IFG series is compatible with GSUB 1.4-1.5, but not with 
  290. earlier versions of GSUB. 
  291.  
  292.  
  293.      IFG,  ELSEG,  ENDIFG and GOTOG are faster and more versatile 
  294. than the corresponding IF, ELSE... series written for SUBMIT. (To 
  295. be  fair,  a  good  deal of IFG was taken from  IF.ASM.)  Out  of 
  296. deference  to the latter,   and to avoid confusion for those  who 
  297. use both, I have added a "G" to all the commands.
  298.  
  299.      IFG offers the same command structure as IF,  plus a  couple 
  300. of  enhancements.   As  with  IF,  only the first letter  of  the 
  301. commands count (as long as there are no spaces). The options are:
  302.  
  303. IFG N[ull] = if command line is null (e.g.,  a null variable in a 
  304.      SUB file)
  305. IFG E[xists] filespec
  306. IFG A[mbig] filespec = if the filespec contains wildcards
  307. IFG M[issing] filespec = if the filespec cannot be found
  308. IFG Z[ero] filespec = if filespec either zero-length or missing
  309.  
  310. Additions:
  311. IFG D[rive] dr = if current drive is dr
  312. IFG U[user] userno = if current user is userno
  313.  
  314. Whether  these conditions are true or false,  IFG will print  the 
  315. information  on  the screen (another improvement).   The  command 
  316. structure is predictable:  if the condition is true, what follows 
  317. the IFG will be executed; if it is false, an ELSEG will be sought 
  318. else commands will be executed following the ENDIFG.  (Leave this 
  319. out   and  you get an error message.)  Since  GSUB  operates   in  
  320. memory rather than on disk, IFG et al perform far faster than the 
  321. IF series.  Like the IF series, IFG allows nesting to any depth.
  322.  
  323. ELSEG  merely skips to the next ENDIFG since,  like ELSE,  it  is 
  324. only executed when the original condition was true.
  325.  
  326. ENDIFG is, like ENDIF, a one-byte file consisting of a "ret".
  327.  
  328. GOTOG  Format: gotog command-number|command [#c]
  329.  
  330. V2.0 allows entry of a command name afte GOTOG.  This name cannot 
  331. contain blanks;  control will pass to the first occurrence of the 
  332. name  in the SUBfile/command line.   Thus GOTOG WS will GOTO  the 
  333. first appearance of WS.   If the command was WS BLURK, it will be 
  334. executed  correctly,  but  you can't write GOTO WS BLURK to  make 
  335. GOTOG avoid (say) an earlier command of WS ZAP.   In such  cases, 
  336. you must use the command-number option.
  337.  
  338. Unlike  GOTO,  GOTOG  can jump backward as well  as  forward  and 
  339. includes a count option,  permitting the creation of loops.  Each
  340. command  is numbered according to its position in  the series  of 
  341. commands  (in  the  SUB file or in immediate   mode).   Only  CCP 
  342. commands are counted, not internal file commands in GSUB. You may 
  343. include the numbers as comments in the SUB file,  but this is not 
  344. necessary.
  345.  
  346. GOTOG xx performs an unconditional goto.  To create a  loop,  use 
  347. the  count option GOTOG xx #c where "c" is the desired number  of 
  348. executions.   The  command number "n" must be between 1 and  255; 
  349. "c" is a single (hex) digit from 1 to F (=15). (If you don't like 
  350. hex numbers, just use the digits 1 through 9.)
  351.  
  352. Examples:
  353. ifg e blurk.com     ;tests existence of file
  354. zlonk {^nr354|}     ;commands between {} don't count for GOTOG
  355. <The directory will now be listed|>   ;message to be displayed
  356. dir
  357. gotog 7             ;goes to 7th command in list (era *.bak)
  358. elseg               ;if blurk.com doesn't exist, then rename
  359. rn zlonk.com=blurk.com
  360. era *.bak
  361. endifg
  362. -----------------------------------------------------------------
  363. ifg u 10       ;if user 10, edit zap.txt
  364. ws zap.txt
  365. elseg
  366. u 10           ;else change user*
  367. gotog 2        ;& go back to edit (the "else" clause will be 
  368. endifg         ;skipped, as always)
  369.           *unlike  SUBMIT,  GSUB  won't get lost when you  change 
  370.           user numbers, but IFG &c must be accessible on disk
  371. -----------------------------------------------------------------
  372. blurk
  373. zap
  374. zlonk
  375. gotog zap #a  ;will go back to zap and execute the loop 10 times
  376.  
  377. NB that GSUB converts all lower-case to upper case (except within 
  378. the  brackets {...} or <...>) when  it creates its buffer in high 
  379. memory.
  380.  
  381.                                ***
  382.  
  383. ALERT.COM  (v1.0)  is for use in SUB files  when  something  goes 
  384. wrong  and  your attention is required.   It will sound the  bell 
  385. twice a second for about a minute (on 4MHz Z80 systems;  ALERT is 
  386. actually  written in 8080 code) and then continue to wait  for  a 
  387. keystroke. 
  388.