home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / bdos / dospls25.ark / IFSKIP.DOC < prev    next >
Encoding:
Text File  |  1986-10-16  |  14.4 KB  |  341 lines

  1.  
  2.                  DOCUMENTATION FOR //IF.COM AND //SKIP.COM
  3.                       82/06/10   Reformatted 85/10/20
  4.  
  5. Modifications 86/10/16 by C.B. Falconer (versions 2.1)
  6.  
  7. The $$$.SUB file is expected to be found on drive A,  user 0.   JOB 1.5 and
  8. CCP+  2.1 place/use it from there.   For use on other than user area 0  you
  9. should be running CCP+ and do any cancellation of jobs with:
  10.      era a0:$$$$$$.sub        (CCP+ will parse this)
  11.                               (the double $'s represent $ to JOB/SUBMIT)
  12. or by
  13.      kill                     (CCP+ command for batch jobs)
  14.  
  15.      ----------------------------------------------------------------
  16.  
  17. Modifications 85/10/20 by C.B. Falconer (versions set to 2.0 from 1.0)
  18.  
  19. //IF  will  function with systems that do not upshift command  lines  (e.g.
  20. CCP+  with the CAPS command executed).   //SKIP considers the ";" as an eol
  21. marker, so that commands can have trailing comment areas, e.g:
  22.  
  23.       "//skip 3; this is a comment"
  24.  
  25.      ----------------------------------------------------------------
  26.  
  27.  
  28. //IF is a program to test various conditions from within a CP/M SUBMIT file
  29. and  then  either  skip the next line in the submit  file,  or  execute  it
  30. normally,  depending  on  the results of the tests.  //IF can test for  the
  31. presence  or  absence  of one or more files,  test a  file  for  emptiness,
  32. compare  two filespecs for equality,  test Submit parameters  for  expected
  33. syntax, test the default drive, and more.
  34.  
  35. When  combined with the //SKIP program the power of //IF can be expanded to
  36. conditionally  execute  entire  blocks of lines  within  the  Submit  file.
  37. IF...THEN...ELSE  structures can be easily implemented within Submit  files
  38. depending upon the parameters supplied, or the status of files on the disks
  39. when the jobstream is submitted.
  40.  
  41.  
  42. THE //IF COMMAND:
  43.  
  44. Syntax:
  45.  
  46. (Square brackets indicate optional parameters)
  47.  
  48.  
  49. //IF [parm1 [parm2]] [:options]
  50.  
  51.    where:
  52.  
  53. <parm1> is a standard CP/M file reference either entered literally, or
  54.      supplied  by  Submit parameter substitution.  The syntax  is  the
  55.      normal D:FILENAME.EXT form.   If either Filename or Extension are
  56.      not entered they default to blanks.  If the Drive is not entered,
  57.      the  current drive is assumed.  If the name or extension  contain
  58.      question mark (?) or asterisk (*) characters,  the file reference
  59.      is said to be ambiguous. Otherwise it is unambiguous.
  60.  
  61. <parm2>  is  an optional second filespec used by some of  the  options
  62.      described below. The defaults are the same as for parm1.
  63.  
  64. <options> is a string of single-character options with no  intervening
  65.      or  trailing blanks.  The option list must be separated from  the
  66.      preceding parameters by at least one blank, and must always begin
  67.      with  a colon (:) to identify it as the option list,  and prevent
  68.      it  from  being confused with parm1 or parm2 if one or  both  are
  69.      omitted.  The entire   option list may also be omitted,  in which
  70.      case the identifying colon should not be entered. The ordering of
  71.      the options within the list is not significant.
  72.  
  73. The  option  list is really a set of tests to be performed upon  the  first
  74. parameter,  parm1.  (Parm1 is assumed to be the name of a file,  but may in
  75. fact be any text at all,  as long as it conforms to the syntax for a  valid
  76. file reference.) If the tests are passed,  the //IF command does nothing at
  77. all, and the next line in the submit file is processed normally.
  78.  
  79. If  however,  any  of the specified option tests fails,  the  //IF  command
  80. modifies  the submit control file (A:$$$.SUB) to skip over the next command
  81. in the file.  Command processing then continues with the line after the one
  82. which was skipped,  if any.  If two mutually exclusive options are included
  83. in the option list, the following line will never be executed.
  84.  
  85.  
  86. Explanation of option characters:
  87.  
  88. A    Ambiguous:  True if parm1 is an ambiguous file  reference.  False
  89.      otherwise.  The  A option does not test to see if a file or files
  90.      exists.  For  example  the parameter *.ASM will pass the  A  test
  91.      regardless of whether there are any .ASM files on the disk.
  92.  
  93. U    Unambiguous:  True  if  parm1 is an unambiguous  file  reference.
  94.      False otherwise.
  95.  
  96. P    Present:  True  if  at least one file exists  which  matches  the
  97.      specification  given in parm1.  Parm1 may be ambiguous (unless of
  98.      course the U option appears in the list)
  99.  
  100. M    Missing:  True if there exists no file which matches the specifi-
  101.      cation given in parm1. Parm1 may be ambiguous.
  102.  
  103. C    Contents:  True  if the file referenced by parm1 exists and  con-
  104.      tains  at  least one record (sector).  If Parm1 is ambiguous  the
  105.      test fails.
  106.  
  107. E    Empty:  True if the file referenced by parm1 exists in the direc-
  108.      tory but contains no data. If Parm1 is ambiguous the test fails.
  109.  
  110. D    Drive substitution:  This option is not really a test, and cannot
  111.      fail as such.  It causes whatever drive has been entered in parm2
  112.      to be moved into parm1 before any testing is done on  parm1.  For
  113.      example  if parm1 were A:TEST.FIL and parm2 were B:  all the  re-
  114.      maining  options would treat parm1 as if it had been  B:TEST.FIL.
  115.      If  parm2 is blank,  or does not contain a drive spec,  parm1  is
  116.      modified to remove any explicit drive spec.  Parm1 then refers to
  117.      the default drive. Note again that the order of the options makes
  118.      no  difference to the program.  The D option is always  performed
  119.      before  any  other  tests,  even if it occurs at the end  of  the
  120.      option list.
  121.  
  122. The  following  three options are matching tests.  They match  portions  of
  123. parm1 against the corresponding portions of parm2.
  124.  
  125. 0    Matches the drivespec portions of parm1 and parm2.  Tests true if
  126.      the same drive is referred to by both.   Note that if one of  the
  127.      drives is explicit and the other is defaulted, the test will pass
  128.      or  not depending upon whether the explicit drive is in fact  the
  129.      current default drive.  If both parm1 and parm2 are missing, this
  130.      test  will  pass,  since both parameters refer by default to  the
  131.      current drive.
  132.  
  133. 1    Matches  the filename portion of parm1 and parm2.  Tests true  if
  134.      the filenames match or are both missing. If either or both of the
  135.      filenames are ambiguous,  the ambiguous characters are considered
  136.      to match the corresponding portion of the other name. For example
  137.      if  parm2  is * this test will always pass.  Note that  only  the
  138.      first 8 characters of the names are tested.
  139.  
  140. 2    Matches the extension (filetype) portion of parm1 and parm2. Same
  141.      as  option  1  except that only the three  characters  after  the
  142.      period of each parameter are tested.
  143.  
  144. No option  list:  If  the option list is omitted  entirely,  the  //IF
  145.      command merely tests to see if anything was entered following the
  146.      word  //IF on the command line.  If the   remainder of  the  line
  147.      (after  Submit parameter substitution) is blank,  the test fails.
  148.      If any non-blank character appears on the line,  the test passes.
  149.      For example the line
  150.  
  151.          //IF $1
  152.  
  153.      tests  to  see if parameter number $1 was defined on  the  Submit
  154.      command line.  If it was not, the line after substitution becomes
  155.      just "//IF ", and the test fails.
  156.  
  157.  
  158. Error Messages:
  159.  
  160. The  following  error messages indicate fatal errors  in  processing.   The
  161. remainder of the submit file is not processed,  and control returns to  the
  162. console.
  163.  
  164. Option "X" not valid....CANCELED
  165.  
  166.      A  character  appears  in the option list which is not  one  of  those
  167. defined above.
  168.  
  169. Error accessing .SUB file....CANCELED
  170.  
  171.      The file A:$$$.SUB could not be found,  or could not be closed, by the
  172. //IF  program.  This  error can also occur if //IF is run from the  console
  173. rather than within a submit file,  or if //IF is the last line in a  submit
  174. file; i.e. there is no next line to skip when a test fails.
  175.  
  176.  
  177.  
  178. THE //SKIP COMMAND:
  179.  
  180. The  skip command is used to unconditionally skip over any number of  lines
  181. within a Submit file. Normally it is used as the line immediately following
  182. an  //IF  command.  In  this way the testing capabilities of  //IF  can  be
  183. extended  to  apply to more than one line of the file.  //SKIP can also  be
  184. used to implement IF...THEN...ELSE structures within Submit files.
  185.  
  186. Syntax: (Square brackets indicate optional parameter.)
  187.  
  188. //SKIP [number]
  189.  
  190.      where:
  191.  
  192. <number>  is a decimal integer in the range 0-127 which indicates  the
  193.      number of lines in the submit file to be skipped. If omitted, the
  194.      number 1 is assumed. The number must be separated from the //SKIP
  195.      command  by  at least one space,  and may not have  any  trailing
  196.      spaces.
  197.  
  198. //Skip operates by evaluating the argument and, if it is greater than zero,
  199. modifying  the  file A:$$$.SUB to cause the system to ignore the  indicated
  200. number of lines. If the argument is 0, //SKIP does nothing at all.
  201.  
  202. Error Messages:
  203.  
  204. The  following  error messages indicate fatal errors  in  processing.   The
  205. remainder of the submit file is not processed,  and control returns to  the
  206. console.
  207.  
  208. Error accessing .SUB file....CANCELED
  209.  
  210.      The file A:$$$.SUB could not be found,  or could not be closed, by the
  211. //SKIP program.  This error can also occur if //SKIP is typed directly from
  212. the console rather than within a submit file.
  213.  
  214. //SKIP argument not numeric....CANCELLED
  215.  
  216.      The <number> parameter contains characters other than 0 to 9.
  217.  
  218. //SKIP argument exceeds file size....CANCELLED
  219.  
  220.      An  attempt was made to skip over more lines than there are  remaining
  221. in the A:$$$.SUB file.
  222.  
  223.  
  224.  
  225. USAGE EXAMPLES:
  226.  
  227. Example 1:  The following Submit file will assemble and load a source file.
  228. The file name is indicated as the first parameter.  If the second parameter
  229. is EDIT,  the file will first be edited.  Some error checking is done. Note
  230. the  use  of  lines beginning with a semicolon to supply  messages  to  the
  231. operator.  CP/M  treats  such lines as comments.  The line numbers are  for
  232. reference purposes, and are not part of the file.
  233.  
  234. [1]  //IF $1 :U2
  235. [2]  //SKIP 2
  236. [3]  ;PARAMETER 1 NOT VALID
  237. [4]  ERA A:$$$$$$.SUB              (use A0:$$$$$$.SUB with CCP+)
  238. [5]  //IF EDIT $2 :U012
  239. [6]  ED $1.ASM
  240. [7]  //IF $1.ASM :C
  241. [8]  ASM $1
  242. [9]  //IF $1.HEX :C
  243. [10] LOAD $1
  244.  
  245. Notes:
  246.  
  247.      Line  1:  Tests that parameter 1 is unambiguous and has a filetype  of
  248. all  blanks.  Parameter  2 is missing,  and is treated as  blanks  for  the
  249. comparison.
  250.  
  251.      Line 2: If the test is passed, lines 3 and 4 are skipped.
  252.  
  253.      Line 3: The operator is informed of an error condition
  254.  
  255.      Line 4:  The submit file is aborted by erasing A:$$$.SUB. Since $ is a
  256. special  character  to SUBMIT,  each one must be represented by two in  the
  257. source file.
  258.  
  259.      Line  5:  The second parameter is tested to see if it is equal to  the
  260. word  "EDIT".  The 0 and 2 options are extra insurance that the  drive  and
  261. filetype are blank.
  262.  
  263.      Line  6:  If the test is passed the file is edited with a filetype  of
  264.  
  265.      Line  7:  The file is tested to see if it contains data.   This  helps
  266. insure that the editor terminated normally.
  267.  
  268.      Line 8: If the test is passed, the file is assembled.
  269.  
  270.      Line  9:  The .HEX file is tested for contents to help insure that the
  271. assembler terminated normally.
  272.  
  273.      Line 10:  If the .HEX file is present, the file is LOADed to produce a
  274.  
  275.  
  276. Example 2:  The following is a skeleton example of how //IF and //SKIP  can
  277. be used to form an IF....THEN....ELSE structure.
  278.  
  279. <-------------------------------------->
  280. <--------- prior submit lines --------->
  281. <-------------------------------------->
  282. //IF <aaaa> <bbbb> :<test>
  283. //SKIP m
  284. <-------------------------------------->
  285. <---- m-1 lines to be executed--------->
  286. <---- if test is FALSE ---------------->
  287. <-------------------------------------->
  288. //SKIP n
  289. <-------------------------------------->
  290. <---- n lines to be executed ---------->
  291. <---- if test is TRUE------------------>
  292. <-------------------------------------->
  293. <---- remainder of submit file to ----->
  294. <---- be executed unconditionally ----->
  295. <-------------------------------------->
  296.  
  297. Notes:
  298.  
  299.      The  //IF condition tests whatever combination of options is  desired.
  300. If  the  conditions are not met,  the //SKIP immediately below is  not  ex-
  301. ecuted.  Instead, control passes through to the lines to be executed if the
  302. test  is  false,  in  effect the ELSE section.  The last line of  the  ELSE
  303. section is another //SKIP which skips past the THEN section (those lines to
  304. be executed if the test is true) and executes the remainder of the file.
  305.  
  306.      If  the //IF test is true,  the first //SKIP statement skips over  the
  307. ELSE section.  The value m is chosen so that the last line skipped over  is
  308. the  second //SKIP statement.   It takes some time to get used to seeing  a
  309. structure where the ELSE comes between the IF and the THEN,  but the struc-
  310. ture is no less valid for being slightly unorthodox.
  311.  
  312.  
  313. PROGRAM NOTES:
  314.  
  315. The  program is written for the 8080 processor and should execute  properly
  316. on 8080, 8085, and Z-80 processors. It has been tested under CP/M80 version
  317. 2.2, but should operate properly with 2.1, 2.0 and 1.4 also.
  318.  
  319. There  is a minor difference in the operation of the C option depending  on
  320. the version used.  If the operating system identifies itself as version 2.0
  321. or  above  (as determined by a call to Function 12) the C option  will  use
  322. Function 35, "Compute File Size" in order to determine if the file contains
  323. any  records.  If the version test shows that the operating system is  pre-
  324. version-2,  the  C option test merely tries to read the first record of the
  325. file.
  326.  
  327. The  only  time  this would make a difference is on  a  Random  file  which
  328. happens  to have no records in the first extent.  The sequential read would
  329. fail,  but the Compute File Size function would properly report the  exist-
  330. ence of records in the file.  While sequential files will test correctly on
  331. any  version,  files which have been created randomly should not be  tested
  332. for contents on CP/M 1.4 or earlier.
  333.  
  334. I  would appreciate being informed of any bugs found in either program,  or
  335. suggestions for expansion or improvement.
  336.  
  337.  
  338.           Gary P. Novosielski,
  339.           21 W. Pierrepont Avenue,
  340.           Rutherford, NJ 07070
  341. f