home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / soundpot / f / if10.lbr / IF.DZC / IF.DOC
Encoding:
Text File  |  1993-10-26  |  8.1 KB  |  265 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                            IF-ELSE-ENDIF Documentation
  9.  
  10.  
  11.                                  For Version 1.0
  12.  
  13.  
  14.                             Written by:  Marc C. Brooks
  15.                                          1124 Redman Rd.
  16.                                          St. Louis, MO 63043
  17.                                          (314)741-4465 (voice)
  18.  
  19.  
  20.  
  21.  
  22.                                   INTRODUCTION
  23.  
  24.              I╞á anΣ it≤ companioε program≤ (ELSE¼á ENDI╞ anΣá GOTO⌐á arσ ì
  25.         direc⌠á out-growth≤á oµá DaviΣ Kirkland'≤ versioε oµá thσá SKIPI╞ ì
  26.         prograφ a≤ printeΣ iε Dr«á Dobb'≤ Journal«á  The∙ sharσ mucΦ codσ ì
  27.         witΦá thσ SKIPI╞ anΣ ╔ aφ eternall∙ gratefu∞ fo≥á Mr«á Kirkland'≤ ì
  28.         inspiration.
  29.  
  30.              I╞á i≤ designeΣ t∩ allo≈ conditiona∞ executioε oµ statement≤ ì
  31.         withiεá ß CP/═ submi⌠ file«á  Becausσ oµ thσ methoΣ useΣ t∩á ski≡ ì
  32.         statement≤ iε thσ submi⌠ file¼á I╞ canno⌠ bσ useΣ iε CP/M+«á  Fo≥ ì
  33.         al∞ othe≥ version≤ oµ CP/M-80¼á though¼á I╞ lend≤ thσ versitilit∙ ì
  34.         oµá thσ standarΣ structureΣ programminτ construc⌠á IF-ELSE-ENDIF«  ì
  35.         GOT╧ i≤ ß companioε prograφ whosσ neeΣ wa≤ discovereΣ whilσ usinτ ì
  36.         IF«á  I⌠á allow≤á forwarΣ (backwarΣ i≤ impossible⌐ jump≤á iεá thσ ì
  37.         submi⌠ t∩ labeleΣ points.
  38.  
  39.              IF¼ ELSE¼ anΣ GOTO¼ wheε executσ froφ thσ CC╨ bu⌠ no⌠ withiε ì
  40.         ßá submi⌠á file¼áá wil∞á explaiεá thei≥á usσá anΣá syntax«á  Thi≤ ì
  41.         document'≤á maiε purposσ i≤ t∩ givσ example≤ iε thσ usσ oµá thesσ ì
  42.         four programs.
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.         Page 1 of 4                          IF Documentation Version 1.0
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.         I.  IF Summary
  73.  
  74.              I╞ i≤ thσ maiε prograφ fo≥ thi≤ package«  I⌠ make≤ decision≤ ì
  75.         oεá whicΦ logica∞ brancΦ oµ thσ submi⌠ shoulΣ bσ taken«á  Iµá thσ ì
  76.         conditioε specifieΣ b∙ thσ I╞ commanΣ i≤ true¼ al∞ command≤ u≡ t∩ ì
  77.         thσá matchinτá ELS┼ o≥ ENDI╞ wil∞ bσ executed«á  Iµá aεá ELS┼á i≤ ì
  78.         encountereΣá whilσ executinτ command¼á t∩ followinτ command≤ wil∞ ì
  79.         bσá skippeΣá unti∞ thσ matchinτ ENDI╞á i≤á encountered«á  Iµá thσ ì
  80.         conditioεá i≤á false¼á command≤ u≡ t∩ anΣ includinτ thσá matchinτ ì
  81.         ELS┼ (iµ i⌠ exists⌐ o≥ ENDI╞ arσ skipped«á  I╞ ha≤ fivσá command≤ ì
  82.         whicΦ decidσ thσ fatσ oµ thσ submit«  The∙ are:
  83.  
  84.              A[mbig] fn     Iµá thσ fε whicΦ appear≤ oε thσ commanΣá linσ ì
  85.         áááááááááááááááááááái≤á aεá ambiguou≤ filσ referencσá  (i.e«á onσ ì
  86.         ááááááááááááááááááááwitΦ aε ¬ o≥ ┐ iε it⌐ thσ conditioε i≤ true.
  87.  
  88.         áááááE[xists] fn    Iµ thσ filσ referenceΣ b∙ thσ fε giveε oε thσ ì
  89.         áááááááááááááááááááácommand line exists, the condition is true.
  90.  
  91.              M[issing] fn   Iµ thσ filσ referenceΣ b∙ thσ fε giveε oε thσ ì
  92.         áááááááááááááááááááácommanΣ linσ caε no⌠ bσ found¼á thσ conditioε ì
  93.         áááááááááááááááááááái≤ true.
  94.  
  95.              N[ull] (fn)    Iµá thσ fε itselµ i≤ missinτ froφ thσ commanΣ ì
  96.         ááááááááááááááááááááline¼á thσ conditioε i≤ true«á  Notσ tha⌠ thσ ì
  97.         ááááááááááááááááááááparathesi≤ '()º d∩ NO╘ appea≥ iε actua∞ use.
  98.  
  99.         áááááZ[ero] fn      Iµ thσ filσ referenceΣ b∙ thσ fε giveε oε thσ ì
  100.         áááááááááááááááááááácommanΣá linσ caε no⌠ bσ founΣ o≥ i≤ oµá zer∩ ì
  101.         áááááááááááááááááááálength¼ thσ conditioε i≤ true.
  102.  
  103.         Notσ tha⌠ onl∙ thσ firs⌠ characte≥ oµ thσ keyworΣ (┴ fo≥ Ambiτ o≥ ì
  104.         whateve≥á i≤á significant«á  Al∞á othe≥ character≤ oµá thσá firs⌠ ì
  105.         paramete≥ arσ ignored«á  Thσ seconΣ paramete≥ MUS╘ exis⌠ fo≥á al∞ ì
  106.         commanΣá excep⌠ witΦ thσ Nul∞ command«á  Iµ aε invaliΣ keyworΣ i≤ ì
  107.         giveεá o≥ thσ fε i≤ missinτ wheε needed¼á I╞ wil∞ givσá aεá erro≥ ì
  108.         messagσá anΣ ski≡ t∩ thσ matchinτ ENDI╞ statement«á  Iµ an∙ othe≥ ì
  109.         error occurs, IF will abort the submit.
  110.  
  111.  
  112.         II.  ELSE Summary
  113.  
  114.              ELS┼á i≤ ß prograφ tha⌠ automaticall∙ skip≤ al∞ command≤á u≡ ì
  115.         t∩á anΣá includigεá thσ matchinτ IF«á  I⌠á i≤á skippeΣá wheεá thσ ì
  116.         preceedinτá I╞á i≤ false¼á s∩ i⌠ wil∞ onl∙ bσ executeΣá wheεá thσ ì
  117.         preceedinτ I╞ i≤ true«á  Iε tha⌠ case¼á ELS┼ shoulΣ ski≡ thσ ELS┼ ì
  118.         clausσá u≡á t∩ thσ ENDI╞ marker«á  Fo≥ tha⌠ reason¼á ELS┼á alway≤ ì
  119.         skip≤ t∩ thσ matchinτ ENDIF«á  IF-ELSE-ENDI╞ group≤ ma∙ bσ nesteΣ ì
  120.         t∩á an∙á deptΦá anΣ ELS┼ wil∞ ski≡ t∩á it≤á ENDIF«á  Iµá ELS┼á i≤ ì
  121.         executeΣ b∙ thσ CC╨ outsidσ ß submit¼ i⌠ wil∞ explaiε it≤ usσ anΣ ì
  122.         exit«  Iµ i⌠ run≤ int∩ an∙ errors¼ i⌠ wil∞ terminatσ thσ submit.
  123.  
  124.  
  125.  
  126.  
  127.         Page 2 of 4                          IF Documentation Version 1.0
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.         III.  ENDIF Summary
  139.  
  140.              ENDI╞ i≤ jus⌠ ß place-marke≥ fo≥ I╞ anΣ ELSE¼ bu⌠ i⌠ mus⌠ bσ ì
  141.         aεá executablσá prograφ becausσ i⌠ wil∞ bσ loadeΣ ever∙ timσá thσ ì
  142.         ELS┼ clausσ oµ aε I╞ i≤ executed«á  Iε it≤ curren⌠ form¼á i⌠ jus⌠ ì
  143.         returns to the CCP.
  144.  
  145.  
  146.         IV.  GOTO Summary
  147.  
  148.              GOT╧ i≤ useΣ t∩ providσ unconditiona∞ skippinτ oµ step≤ iε ß ì
  149.         submi⌠ procedure«  T∩ usσ it¼ jus⌠ pu⌠ GOT╧ 'labelº iε thσ submi⌠ ì
  150.         prograφ wherσ desired«á  Somewherσ late≥ iε thσ submit¼á placσá ß ì
  151.         labe∞á a≤ ß commen⌠ line«á  Label≤ takσ thσ forφ oµ an∙ strinτ oµ ì
  152.         non-whitespacσ character≤ terminateΣ b∙ thσ enΣ oµ thσ linσ o≥á ß ì
  153.         whitespacσá character«á  Whitespacσ character≤ arσ an∙ character≤ ì
  154.         lowe≥ iε thσ ASCI╔ collatinτ sequencσ thaε '!º (i.e«á space¼ tab¼ ì
  155.         etc.)  Some examples of GOTO are:
  156.  
  157.                   GOTO END-OF-COMPILE
  158.                   GOTO SKIP           terminate the rest of the submit
  159.                   GOTO 1200
  160.  
  161.              Iε thσ seconΣ example¼ thσ tex⌠ followinτ thσ worΣ 'SKIPº i≤ ì
  162.         al∞á ignored«á  Thσá correspondinτ t∩ thσ abovσá GOT╧á statement≤ ì
  163.         might look like this:
  164.  
  165.                   ;END-OF-COMPIL┼  Al∞ thσ passe≤ oµ thσ compilσ arσ done
  166.                   ;SKIP
  167.                   ;1200
  168.  
  169.              Oncσá again¼á iε thσ firs⌠ example¼á thσ tex⌠ followinτá thσ ì
  170.         labe∞ i≤ completel∙ ignored«  Also¼ duσ t∩ limitation≤ withiε thσ ì
  171.         CCP, the case of the label characters is not significant.
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.         Page 3 of 4                          IF Documentation Version 1.0
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.         V.  EXAMPLES
  205.  
  206.         Example 1.     pp -o edit.tm1 edit.c
  207.                        p1 -o edit.tm2 edit.tm1
  208.                        era edit.tm1
  209.                        IF ZERO EDIT.TM2      did the p1 passed find errors ?
  210.                             era edit.tm2
  211.                             GOTO LIST-FILE
  212.                        ELSE
  213.                             p280 -o edit.s edit.tm2
  214.                             era edit.tm2
  215.                             as80 edit.s
  216.                             era edit.s
  217.                             link -o edit.com edit.o
  218.                        ENDIF
  219.                        IF ZERO EDIT.COM       did the link fail ?
  220.                             ;LIST-FILE      ; list the source file
  221.                             list edit.c
  222.                        ENDIF
  223.  
  224.         Example 2:     IF Null $1
  225.                             ;ERROR -- You must supply a file to be compiled
  226.                        ELSE
  227.                        IF Ambig $1
  228.                             ;ERRO╥á-- Yo⌡áma∙áno⌠ usσáambiguou≤áfilσ names
  229.                        ELSE
  230.                        IF Missing $1.bas
  231.                             ;ERROR -- I can't find $1 
  232.                        ELSE
  233.                             ; all okay so lets compile the program
  234.                             CB80 $1.bas $3
  235.                             LK80 $1 my.lib
  236.                             IF Null $2
  237.                             ELSE
  238.                                  list $1.bas
  239.                             ENDIF
  240.                        ENDIF
  241.                        ENDI╞       ╗ thesσ tw∩ ENDIF'≤ aren'⌠ necessary,
  242.                        ENDIF       ; just good programming.
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.         Page 4 of 4                          IF Documentation Version 1.0
  260.  
  261.  
  262.  
  263.  
  264.  
  265.