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 / CPM / CATLOG / KPRTLSTP.LBR / KPRTLST+.BQS / KPRTLST+.BAS
BASIC Source File  |  2000-06-30  |  14KB  |  602 lines

  1. REM -------------[ PRINTLST.BAS (Prints MAST.LST files) ]-----------------\
  2.     \
  3.     SPECIAL VERSION FOR KAYPRO + LEGACY TIME CLOCK \
  4.     \
  5.     \
  6.     Program written and (C) 1985 by Steven L. Sanders\
  7.     \
  8.     Date written - November 24, 1984\
  9.     \
  10.     Version 1, revision 3\
  11.     \
  12.     Language - CBASIC Compiler (CB80)\
  13.     \
  14.     Designed for use with a video-able Kaypro computer or\
  15.     ADM3-A terminal.\
  16.     \
  17.     This program will output the contents of the MAST.LST file\
  18.     generated by XCATxx.COM into a 3-across format either to the\
  19.     CRT, printer, or diskfile.  I found all the other listing programs\
  20.     to be big space-wasters when it came to the number of sheets\
  21.     needed to print-out a big catalog.  PRINTLST ignores all other\
  22.     disk numbers except for the first one generated by XCAT, if you\
  23.     need a cross-ref listing then use XCAT's list output function.\
  24.     \
  25.     To use, run XCATxx on your MAST.CAT file first and choose the\
  26.     diskfile output option and generate the needed MAST.LST file.\
  27.     PRINTLST will look for MAST.LST on the logged du:, read it in\
  28.     and then generate the 3-across format to CRT, printer, or disk.\
  29.     \
  30.     \
  31.     Revision notes \
  32.     \
  33.     Vers 1.3 - Fixed a bug from 1.2 that would cause the program to \
  34.     barf when it encountered an overrun line of nothing but disk numbers.\
  35.     It will now ignore these lines and continue with the next filename\
  36.     to be processed.\
  37.     \
  38. ----------------------------[ (C)opyrights ]---------------------------------\
  39.  
  40.     copyright1$ =\
  41.     "Portions of this program (C)1983, 1984 by Digital Research  "
  42.  
  43.     copyright2$ =\
  44.     "  The rest is (C) 1985 by Steven L. Sanders"
  45.  
  46. REM ------------------------[ DEFINE CONSTANTS ]-----------------------------\
  47.  
  48.     vers$ =        "1.3"        REM current vers and rev
  49.  
  50.     false% =     0        REM true and false used for
  51.     true% =     NOT false%    REM while/wend loops
  52.     bell$ =     CHR$(07h)    REM console bell
  53.     cr$ =         CHR$(0dh)    REM carriage return
  54.     clr$ =        CHR$(1ah)    REM clear screen
  55.     esc$ =        CHR$(1bh)    REM ESCape
  56.     eos$ =        CHR$(017h)    REM clear to end of screen
  57.     formfeed$ =    CHR$(0ch)    REM printer formfeed
  58.  
  59. REM ----------------------[ KAYPRO VIDEO CODES ]-----------------------------\
  60.  
  61.     inv.on$ =     esc$ + "B0"    REM inverse video ON
  62.     inv.off$ =     esc$ + "C0"    REM inverse video OFF
  63.     half.on$ =    esc$ + "B1"    REM half intensity ON
  64.     half.off$ =    esc$ + "C1"    REM half intensity OFF
  65.     blink.on$ =    esc$ + "B2"    REM blink ON
  66.     blink.off$ =    esc$ + "C2"    REM blink OFF
  67.     cur.on$ =    esc$ + "B4"    REM cursor on
  68.     cur.off$ =    esc$ + "C4"    REM cursor off
  69.     save.cur$ =     esc$ + "B6"    REM save current cursor position
  70.     rest.cur$ =     esc$ + "C6"    REM restore cursor position
  71.     stat.on$ =     esc$ + "B7"    REM enable status line
  72.     stat.off$ =     esc$ + "C7"    REM disable status line
  73.     pos.cur$ =    esc$ + "=8 "    REM load cursor to col 1 line 25
  74.  
  75. REM --------------------[ DEFINE FUNCTIONS ]----------------------------------\
  76.  
  77. REM position cursor
  78.  
  79.     DEF fn.cursor$(v%,h%)
  80.         PRINT esc$ + "=" + CHR$(v%+32) + CHR$(h%+32);
  81.         RETURN
  82.     FEND
  83.  
  84. REM this function will center a string
  85.  
  86.     DEF fn.center%(data$)
  87.         center% = (80 - LEN(data$))/2
  88.         PRINT TAB(center%);data$;
  89.         RETURN
  90.     FEND
  91.     
  92. REM turns up a clean page under title header
  93.  
  94.     DEF fn.new.screen%
  95.         PRINT FN.CURSOR$(4,0);eos$;
  96.         RETURN
  97.     FEND
  98.  
  99.     DEF fn.screen.two%
  100.         PRINT FN.CURSOR$(2,0);eos$;
  101.         RETURN
  102.     FEND
  103.  
  104.     file.mast$ =    "mast.lst"    REM source MAST.LST
  105.  
  106.     sep$ =        "  |  "        REM file seperator
  107.     fil.sep$ =    " | "        REM output file seperator
  108.  
  109. REM -------------------[ program code begins ]--------------------------\
  110.  
  111. begin:
  112.  
  113.     ON ERROR GOTO error.handler    REM take care of problems
  114.  
  115.     PRINT clr$ + inv.on$ + half.on$ +\
  116.     "  PRINTLST v"+vers$+\
  117.     " - Formats the MAST.LST file   (C)1985 Steven Sanders  " + \
  118.     inv.off$ + half.off$
  119.  
  120.     GOSUB clock
  121.  
  122.     PRINT save.cur$+stat.on$+pos.cur$+\
  123. "                 Time: " + clock.time$ + "    Date: " + military.date$
  124.  
  125.     PRINT rest.cur$;
  126.  
  127.     PRINT:PRINT:PRINT:PRINT\
  128.     "  Enter a <RETURN> now to abort, or select -"
  129.     PRINT:PRINT\ 
  130.     "  Output to: "+inv.on$+"<P>"+inv.off$+"rinter, "+\
  131.     inv.on$+"<C>"+inv.off$+"RT, or "+\
  132.     inv.on$+"<D>"+inv.off$+"iskfile?  ";
  133.  
  134. well:
  135.  
  136.     PRINT bell$;
  137.  
  138.     answer% = INKEY
  139.  
  140.     IF answer% = 0dh THEN PRINT stat.off$ + clr$ : STOP
  141.  
  142.     IF UCASE$(CHR$(answer%)) = "P" THEN\
  143.     PRINT "Printer":\
  144.     GOTO list.it
  145.  
  146.     IF UCASE$(CHR$(answer%)) = "D" THEN\
  147.     PRINT "Diskfile":\
  148.     GOTO create.it
  149.  
  150.     IF UCASE$(CHR$(answer%)) <> "C" THEN GOTO well
  151.  
  152.     PRINT "CRT"
  153.  
  154. REM -----------------------[ output to crt ]----------------------------------\
  155.  
  156.     GOSUB chek.for.file
  157.  
  158.     IF END #1 THEN thats.all
  159.  
  160.     count% = 1
  161.     line% = 1
  162.  
  163.     dummy% = fn.screen.two%
  164.  
  165.     PRINT cur.off$;        REM turn cursor off until exit
  166.  
  167.     PRINT\
  168. "filename.typ  -  dsk  |  filename.typ  -  dsk  |  filename.typ  -  dsk"
  169.     PRINT\
  170. "----------------------------------------------------------------------"
  171.  
  172.     PRINT
  173.  
  174.     WHILE true%
  175.  
  176. do.it:
  177.  
  178.         IF count% > 3 THEN\
  179.         count% = 1:\
  180.         PRINT
  181.  
  182.         READ #1;LINE input.line$
  183.  
  184.         IF MID$(input.line$,4,5) = "DONE:" THEN\
  185.         PRINT input.line$:\
  186.         GOTO do.it
  187.  
  188.         IF LEFT$(input.line$,15) = "               " THEN\
  189.         GOTO do.it
  190.  
  191.         IF MID$(input.line$,15,6) = "UNIQUE" THEN\
  192.         PRINT input.line$:\
  193.         GOTO thats.all
  194.  
  195.         PRINT LEFT$(input.line$,20);
  196.  
  197.         IF count% = 1 OR count% = 2 THEN \
  198.         PRINT sep$;
  199.  
  200.         line% = line% + 1
  201.         count% = count% + 1
  202.  
  203.         IF line% <= 51 THEN GOTO do.it
  204.  
  205.         line% = 1
  206.  
  207.         PRINT:PRINT blink.on$ + " [ any key or <Q>uit ] " +\
  208.          blink.off$;
  209.  
  210. go.or.no:
  211.  
  212.         dummy% = INKEY
  213.  
  214.         IF UCASE$(CHR$(dummy%)) = "Q" THEN\
  215.         PRINT cr$;"                         ";cr$;:\
  216.         CLOSE 1:\
  217.         PRINT stat.off$+clr$:\
  218.         PRINT cur.on$:\        REM turn cursor back on again
  219.         STOP\
  220.         ELSE\
  221.         dummy% = fn.new.screen%:\
  222.         GOTO do.it
  223.  
  224.     WEND
  225.  
  226. thats.all:
  227.  
  228.     PRINT cur.on$+stat.off$+clr$
  229.     PRINT "All done." + bell$
  230.  
  231.     STOP
  232.  
  233. REM ------------------------[ output to printer ]----------------------------\
  234.  
  235. list.it:
  236.  
  237.     GOSUB chek.for.file
  238.  
  239.     dummy% = fn.new.screen%
  240.  
  241.     PRINT:PRINT:PRINT\
  242. "               ++ Outputting MAST.LST to the printer ++"
  243.  
  244.     PRINT:PRINT:PRINT\
  245. "                  >> Press <A> to abort printing <<";
  246.  
  247.     IF END #1 THEN all.printed
  248.  
  249.     count% = 1
  250.     line% = 1
  251.     page% = 1
  252.  
  253.     LPRINTER WIDTH 80
  254.  
  255. new.page:
  256.  
  257.     PRINT\
  258. "MAST.LST - Master CP/M Catalog as of " + clock.date$ + " at " + clock.time$+ \
  259.     "            page";page%
  260.  
  261.     PRINT:PRINT\
  262. "filename.typ  -  dsk  |  filename.typ  -  dsk  |  filename.typ  -  dsk"
  263.     PRINT\
  264. "----------------------------------------------------------------------"
  265.  
  266.     IF page% = 1 THEN PRINT
  267.  
  268.     WHILE true%
  269.  
  270. doing.it:
  271.  
  272.         IF count% > 3 THEN\
  273.         count% = 1:\
  274.         PRINT
  275.  
  276.         READ #1;LINE input.line$
  277.  
  278.             WHILE CONSTAT%
  279.  
  280.                 abort% = CONCHAR%
  281.  
  282.             IF UCASE$(CHR$(abort%)) = "A" THEN\
  283.             CONSOLE : CLOSE 1 :\
  284.             PRINT:PRINT:PRINT stat.off$+blink.on$+\
  285.         "                        [ Printing ABORTED ]" +\
  286.             blink.off$ + bell$:\
  287.             STOP
  288.  
  289.             WEND
  290.  
  291.         IF LEFT$(input.line$,15) = "               " THEN\
  292.         GOTO doing.it
  293.  
  294.         IF MID$(input.line$,4,5) = "DONE:" THEN\
  295.         PRINT input.line$:\
  296.         GOTO doing.it
  297.  
  298.         IF MID$(input.line$,15,6) = "UNIQUE" THEN\
  299.         PRINT input.line$:\
  300.         GOTO all.printed
  301.  
  302.         PRINT LEFT$(input.line$,20);
  303.  
  304.         IF count% = 1 OR count% = 2 THEN \
  305.         PRINT sep$;
  306.  
  307.         line% = line% + 1
  308.         count% = count% + 1
  309.  
  310.         IF line% <= 171 THEN GOTO doing.it
  311.  
  312.         line% = 1
  313.  
  314.         PRINT formfeed$
  315.  
  316.         page% = page% + 1
  317.  
  318.         GOTO new.page
  319.  
  320.     WEND
  321.  
  322. all.printed:
  323.  
  324.     CONSOLE
  325.  
  326.     CLOSE 1
  327.  
  328.  
  329.     PRINT stat.off$+clr$
  330.  
  331.     PRINT:PRINT "All done." + bell$
  332.  
  333.     STOP
  334.  
  335. REM ------------------------[ output to diskfile ]----------------------------\
  336.  
  337. create.it:
  338.  
  339.     GOSUB chek.for.file
  340.  
  341.     dummy% = fn.new.screen%
  342.  
  343.     PRINT:PRINT:PRINT\
  344. "Enter drive to create MASTER.LST on (A,B,C,or c/r for default): ";
  345.  
  346. which.drive:
  347.  
  348.     PRINT bell$;
  349.  
  350.     answer% = INKEY
  351.  
  352.     IF answer% = 0dh THEN\
  353.     PRINT "Default":\
  354.     file.form$ = "MASTER.LST":\
  355.     GOTO get.on.with.it
  356.  
  357.     IF UCASE$(CHR$(answer%)) = "A" THEN\
  358.     PRINT "A":\
  359.     file.form$ = "A:MASTER.LST":\
  360.     GOTO get.on.with.it
  361.  
  362.     IF UCASE$(CHR$(answer%)) = "B" THEN\
  363.     PRINT "B":\
  364.     file.form$ = "B:MASTER.LST":\
  365.     GOTO get.on.with.it
  366.  
  367.     IF UCASE$(CHR$(answer%)) = "C" THEN\
  368.     PRINT "C":\
  369.     file.form$ = "C:MASTER.LST":\
  370.     GOTO get.on.with.it
  371.  
  372.     GOTO which.drive
  373.  
  374. get.on.with.it:
  375.  
  376.     IF SIZE(file.form$) THEN\
  377.     dummy% = fn.new.screen%:\
  378.     PRINT:PRINT:PRINT:PRINT bell$ +\
  379. "          Program ABORTED!  MASTER.LST file already exists!":\
  380.     PRINT stat.off$:\
  381.     STOP\
  382.     ELSE\
  383.     CREATE file.form$ AS 2
  384.  
  385.     PRINT:PRINT:PRINT\
  386. "            ++ Creating  " + file.form$ + " - Press <A> to abort ++"
  387.  
  388.     IF END #1 THEN all.formatted
  389.  
  390.     line.number% = 1
  391.  
  392.     count% = 1
  393.  
  394.     PRINT:PRINT
  395.  
  396.     PRINT USING "&";#2;\
  397.     "MASTER.LST - Master CP/M Catalog as of " + clock.date$ +\
  398.     "  " + clock.time$
  399.  
  400.     PRINT USING "&";#2;" "
  401.     PRINT USING "&";#2;\
  402. "filename.typ  -  dsk  |  filename.typ  -  dsk  |  filename.typ  -  dsk"
  403.     PRINT USING "&";#2;\
  404. "----------------------------------------------------------------------"
  405.  
  406.     WHILE true%
  407.  
  408. formatting.it:
  409.  
  410.         IF count% = 4 THEN\
  411.         count% = 1:\
  412.         line.number% = line.number% + 1:\
  413.     PRINT cr$;"                        Now working line#";line.number%;:\
  414.         GOSUB output.the.line
  415.  
  416.         READ #1;LINE input.line$
  417.  
  418.             WHILE CONSTAT%
  419.  
  420.                 abort% = CONCHAR%
  421.  
  422.             IF UCASE$(CHR$(abort%)) = "A" THEN\
  423.             CLOSE 1 : CLOSE 2 :\
  424.             PRINT:PRINT:PRINT blink.on$+\
  425.             "                             [ ABORTED ]"+\
  426.             blink.off$ + bell$:\
  427.             PRINT stat.off$;:\
  428.             STOP
  429.  
  430.             WEND
  431.  
  432.         IF LEFT$(input.line$,15) = "                " THEN\
  433.         GOTO formatting.it
  434.  
  435.         IF MID$(input.line$,4,5) = "DONE:" THEN\
  436.         done$ = input.line$:\
  437.         PRINT USING "&";#2;input.line$:\
  438.         GOTO formatting.it
  439.  
  440.         IF MID$(input.line$,15,6) = "UNIQUE" THEN\
  441.         done2$ = input.line$:\
  442.         PRINT USING "&";#2;input.line$:\
  443.         GOTO all.formatted
  444.  
  445.         IF count% = 1 THEN file1$ = LEFT$(input.line$,20)
  446.  
  447.         IF count% = 2 THEN file2$ = LEFT$(input.line$,20)
  448.  
  449.         IF count% = 3 THEN file3$ = LEFT$(input.line$,20)
  450.  
  451.         count% = count% + 1
  452.  
  453.         GOTO formatting.it
  454.  
  455.     WEND
  456.  
  457. output.the.line:
  458.  
  459.     PRINT USING "& & & & &";#2;file1$,fil.sep$,file2$,fil.sep$,file3$
  460.  
  461.     RETURN
  462.  
  463. all.formatted:
  464.  
  465.     CLOSE 1
  466.     CLOSE 2
  467.  
  468.     dummy% = fn.new.screen%
  469.  
  470.     PRINT:PRINT:PRINT:PRINT\
  471. "                         " + done$
  472.     PRINT\
  473. "                         " + done2$ + bell$
  474.  
  475.     PRINT stat.off$
  476.  
  477.     STOP
  478.  
  479. chek.for.file:
  480.  
  481.     IF NOT SIZE(file.mast$) THEN \
  482.     PRINT:PRINT:PRINT blink.on$+\
  483.     "  >> Unable to find MAST.LST on current drive/user <<" +\
  484.     blink.off$+bell$:\
  485.     STOP \
  486.     ELSE \
  487.     OPEN file.mast$ AS 1
  488.  
  489.     RETURN
  490.  
  491. REM -------------------[ Legacy clock routines ]-----------------------------\
  492.     \
  493.     For use with the Legacy Computer Systems Z-80 piggy-back\
  494.     real-time clock board.  Be sure to set port equates below \
  495.     depending on whether you have the KP2/4 board or the KP10 board.
  496.  
  497. clock:
  498.  
  499.     DIM TIME(13)
  500.  
  501.     FOR digit = 0 TO 12
  502.  
  503.     Z1 = 079h : Z2 = 07bh    REM for Kaypro 10 board
  504.  
  505.     REM Kaypro 2/4 board uses  Z1 = 0ah : z2 = 0bh
  506.  
  507.     OUT Z1,0         REM preset data reg
  508.     OUT Z2,0cfh         REM set mode3
  509.     OUT Z2,0        REM all outputs mask
  510.     OUT Z1,digit         REM send address
  511.     OUT Z1,digit+128    REM set latch
  512.     OUT Z1,digit
  513.  
  514.     OUT Z1,020h        REM set read line
  515.     OUT Z2,0cfh         REM set mode3
  516.     OUT Z2,0fh         REM d7-d4 are still output
  517.     OUT Z1,020h
  518.  
  519.     REM read data
  520.  
  521.     D1 = INP(Z1) AND 0fh
  522.  
  523.     TIME(digit) = D1
  524.  
  525.     NEXT digit
  526.  
  527. REM time is given in 24 hr format HH:MM:SS
  528.  
  529.     clock.time$ = CHR$((TIME(5)-8)+48)+CHR$(TIME(4)+48)+":"+ \
  530.         CHR$(TIME(3)+48)+CHR$(TIME(2)+48)+":"+ \
  531.         CHR$(TIME(1)+48)+CHR$(TIME(0)+48)
  532.  
  533.     IF TIME(6) = 0 THEN day$ = "Sunday"
  534.     IF TIME(6) = 1 THEN day$ = "Monday"
  535.     IF TIME(6) = 2 THEN day$ = "Tuesday"
  536.     IF TIME(6) = 3 THEN day$ = "Wednesday"
  537.     IF TIME(6) = 4 THEN day$ = "Thursday"
  538.     IF TIME(6) = 5 THEN day$ = "Friday"
  539.     IF TIME(6) = 6 THEN day$ = "Saturday"
  540.  
  541.     clock.day$ = day$
  542.  
  543. REM the date is MM/DD/YY format
  544.  
  545.     clock.date$ = CHR$(TIME(10)+48)+CHR$(TIME(9)+48)+ "/" +\
  546.             CHR$(TIME(8)+48)+CHR$(TIME(7)+48)+ "/" +\
  547.             CHR$(TIME(12)+48)+CHR$(TIME(11)+48)
  548.  
  549.     todays.date$ = clock.date$
  550.  
  551.     clock.year$ = CHR$(TIME(12)+48)+CHR$(TIME(11)+48)
  552.  
  553.     IF CHR$(TIME(10)+48)+CHR$(TIME(9)+48) = "01" THEN\
  554.         month$ = "Jan"
  555.     IF CHR$(TIME(10)+48)+CHR$(TIME(9)+48) = "02" THEN\
  556.         month$ = "Feb"
  557.     IF CHR$(TIME(10)+48)+CHR$(TIME(9)+48) = "03" THEN\
  558.         month$ = "Mar"
  559.     IF CHR$(TIME(10)+48)+CHR$(TIME(9)+48) = "04" THEN\
  560.         month$ = "Apr"
  561.     IF CHR$(TIME(10)+48)+CHR$(TIME(9)+48) = "05" THEN\
  562.         month$ = "May"
  563.     IF CHR$(TIME(10)+48)+CHR$(TIME(9)+48) = "06" THEN\
  564.         month$ = "Jun"
  565.     IF CHR$(TIME(10)+48)+CHR$(TIME(9)+48) = "07" THEN\
  566.         month$ = "Jul"
  567.     IF CHR$(TIME(10)+48)+CHR$(TIME(9)+48) = "08" THEN\
  568.         month$ = "Aug"
  569.     IF CHR$(TIME(10)+48)+CHR$(TIME(9)+48) = "09" THEN\
  570.         month$ = "Sep"
  571.     IF CHR$(TIME(10)+48)+CHR$(TIME(9)+48) = "10" THEN\
  572.         month$ = "Oct"
  573.     IF CHR$(TIME(10)+48)+CHR$(TIME(9)+48) = "11" THEN\
  574.         month$ = "Nov"
  575.     IF CHR$(TIME(10)+48)+CHR$(TIME(9)+48) = "12" THEN\
  576.         month$ = "Dec"
  577.  
  578.     military.date$ = CHR$(TIME(8)+48)+CHR$(TIME(7)+48) + "-" +\
  579.              month$ + "-" + clock.year$
  580.             
  581.     RETURN
  582.  
  583. REM ----------------------------[ error handler ]----------------------------\
  584.  
  585. error.handler:
  586.  
  587.     IF ERR = "DW" OR ERR = "ME" THEN\
  588.     dummy% =fn.new.screen%:\
  589.     PRINT:PRINT\
  590. "                Operating system reports an error!!":\
  591.     PRINT:PRINT\
  592. "                Check disk for FREE space available" + bell$\
  593.     ELSE\
  594.     dummy% = fn.new.screen%:\
  595.     PRINT:PRINT bell$ +\
  596. "                CB80 Error Code --> ";err
  597.  
  598.     PRINT cur.on$        REM in case we bailed out in CRT mode
  599.  
  600.     STOP
  601.  
  602. REM --------------------------[ the end ... ]-------------------------------\