1000 ! SPQ.BAC 1005 INTEGER : EXTEND 1010 ; '** Spooler utility **' 1020 ; ' Ver X.04, 1985-04-24' 1030 ; ' Copyright 1984 Dataindustrier AB' 1040 ; 1050 ! * Writen by Jan-Erik Claesson 1060 ! ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** 1070 ! * 1080 ! * Ver date / Ver nr / Sign / Note 1090 ! * 84-08-08 / X.00 / JEC / Main 1100 ! * 84-10-01 / X.01 / JEC / New functions 1110 ! * 85-01-01 / X.02 / JEC / Info on parallell printer 1120 ! * 85-04-24 / X.03 / BL / Accessible from DOS, FNStartpar$ handling 1130 ! * 85-04-24 / X.04 / BL / DCWAI -> NETCALL 1140 ! * 1150 ! ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** 1160 ! * 1170 ! EJECT 1180 ! ***************************************** 1190 ! * 1200 ! * Main routine 1210 ! * 1220 Baud$=" 75 110 300 600 1200 2400 4800 9600 19200" 1230 Buff$="" : POKE VAROOT(Buff$),0,1,0,245,0,1 1240 IF FNGetstat(254) THEN ; 'You must be logged in!.' : GOTO 1440 1250 Com$=FNStartpar$ : IF LEN(Com$) GOTO 1420 1260 ; 'Functions:' 1270 ; : ; 'l<,nr> - list a spoolqueue.' 1280 ; 'i - get spooler information.' 1290 ; 's<,nr> - stop current printing.' 1300 ; 'p - local rpr: conversion' 1310 ; 'r<,nr,PFN> - remove a file from a spoolqueue.' 1320 IF (Ownpriv AND (4))<>4 GOTO 1370 1330 ; 'm<,nr,nr,PFN> - move a file first into a spoolqueue.' 1340 ; 'c<,nr> - clear a spoolqueue.' 1350 ; 'g - generate a initfile for a spooler.' 1360 ; 'b - set remote baud rate.' 1370 ; 1380 ; 'A command ending with >dev will direct output to dev.' 1390 ; 1400 ; 'Choose function:'; 1410 INPUT LINE Com$ : Com$=LEFT$(Com$,LEN(Com$)-2) 1420 IF FNExec(Com$) IF FNChkdos=0 GOTO 1400 1430 ! 1440 ; FNExit 1450 ! ------------------------------------------------- 1460 ! -------- Decode Command ----------------------- 1470 ! ------------------------------------------------- 1480 ! 1490 DEF FNExec(Com$) 1500 ; 1510 IF INSTR(1,Com$,'>') THEN OPEN RIGHT$(Com$,INSTR(1,Com$,'>')+1.) AS FILE 1 ELSE OPEN 'CON:' AS FILE 1 1520 IF LEN(Com$)>2 Opt$=RIGHT$(Com$,3) ELSE Opt$="" 1530 I=INSTR(1,"lisprmcgb",MID$(Com$,1,1)) 1540 IF I=0 I=INSTR(1,"LISPRMCGB",MID$(Com$,1,1)) 1550 IF I=1 IF Opt$="" I=FNList("0") : I=FNList("1") : I=FNList("2") : RETURN FNList("3") ELSE RETURN FNList(Opt$) 1560 IF I=2 RETURN FNInfo 1570 IF I=3 RETURN FNStop(Opt$) 1580 IF I=4 RETURN FNRpr 1590 IF I=5 RETURN FNRem(Opt$) 1600 IF (Ownpriv AND 4)<>4 RETURN -1 1610 IF I=6 RETURN FNMove(Opt$) 1620 IF I=7 RETURN FNClear(Opt$) 1630 IF I=8 RETURN FNGen 1640 IF I=9 RETURN FNSetbaud 1650 RETURN -1 1660 FNEND 1670 ! ------------------------------------------------- 1680 ! ------------- Get user status ------------------- 1690 ! ------------------------------------------------- 1700 DEF FNGetstat(Usernr) 1710 IF FNTalknet(14,0,0,0,Usernr,0) THEN RETURN -1 1720 Usrname$=MID$(Buff$,40,8) 1730 Ownpriv=ASCII(MID$(Buff$,51,1)) 1740 RETURN 0 1750 FNEND 1760 ! -------------------------------------------------- 1770 ! --------- Net Communication ---------------------- 1780 ! -------------------------------------------------- 1790 ! Netcommunication 1800 DEF FNTalknet(Fc,Sfc,B,C,D,E) LOCAL Z 1810 POKE 64798,255 1820 POKE 64961,Fc : POKE 64962,Sfc : POKE 64963,B,C 1830 POKE 64965,D,E : Z=CALL(24615) 1840 RETURN PEEK(64962) 1850 FNEND 1860 ! ---------------------------------------------------- 1870 ! ------------ Local rpr: conversion ----------------- 1880 ! ---------------------------------------------------- 1890 ! Local rpr: conversion 1900 DEF FNRpr 1910 IF FNTalknet(14,7,0,0,0,0) ; 'Net error.' : RETURN 0 1920 A$=CHR$(48+PEEK(VARPTR(Buff$)+13)) 1930 B$=CHR$(48+(PEEK(-541) AND 15)) 1940 ; #1,'Remote printer conversion:' 1950 ; #1 1960 ; #1,'Default conversion in central rpr: = rp'+A$+':' 1970 ; #1,'Local conversion rpr: = rp'+B$+':' 1980 ; 'New device number for conversion:'; 1990 INPUT LINE A$ : A$=LEFT$(A$,1) 2000 IF A$<'0' OR A$>'9' GOTO 1980 2010 IF LEN(A$)<>1 GOTO 1980 2020 POKE -541,ASCII(A$)-48+128 2030 ; : ; #1,'Local conversion now set to rpr: = rp'+A$+':' 2040 RETURN 0 2050 FNEND 2060 ! ----------------------------------------------------- 2070 ! ------------- Get spooler information -------------- 2080 ! ----------------------------------------------------- 2090 DEF FNInfo 2100 IF FNTalknet(14,7,0,0,0,0) ; 'Net error.' : RETURN 0 2110 Pos=VARPTR(Buff$) 2120 Spallow=PEEK(Pos) : Netinfo=PEEK(Pos+1) 2130 Ihdr=PEEK(Pos+2) : Sp1is=PEEK(Pos+3) 2140 V24a=PEEK(Pos+4) : V24b=PEEK(Pos+5) 2150 Uarta=PEEK(Pos+6) : Uartb=PEEK(Pos+7) 2160 Active=PEEK(Pos+8) : Prqcnt=PEEK(Pos+9) 2170 Quecnt=PEEK(Pos+10) : Prqnr=PEEK2(Pos+11) 2180 Rpr=PEEK(Pos+13) 2190 ; #1,'Spooler information:' 2200 ; #1 2210 ; #1,'printer ph.dev baudrate headerfile' 2220 ; #1,'----------------------------------' 2230 FOR I=0 TO 3 2240 ; #1,'rpr'+CHR$(I+48)+': '; 2250 IF Uarta=I AND ((Netinfo AND 16)=16) ; #1,'uarta switch '; : GOTO 2310 2260 IF Uartb=I AND ((Netinfo AND 32)=32) ; #1,'uartb switch '; : GOTO 2310 2270 IF Sp1is=I AND ((Netinfo AND 8)=8) ; #1,'sp1 parall. '; : GOTO 2310 2280 IF (V24a/16)=I AND ((Netinfo AND 1)=1) ; #1,'v24a '+MID$(Baud$,(V24a AND 15)*8,8); : GOTO 2310 2290 IF (V24b/16)=I AND ((Netinfo AND 128)=128) ; #1,'v24b '+MID$(Baud$,(V24b AND 15)*8,8); : GOTO 2310 2300 ; #1,'not in use ' : GOTO 2330 2310 IF (2^I AND Ihdr) ; #1.,'yes '; ELSE ; #1.,'no '; 2320 ; #1 2330 NEXT I 2340 ; #1 : ; #1,'central rpr conversion rpr: = rp'+CHR$(48+Rpr)+': (default)' 2350 ; #1,'local rpr conversion rpr: = rp'+CHR$(48+(PEEK(-541) AND 15))+':' 2360 I=FNShowform 2370 RETURN 0 2380 FNEND 2390 ! ----------------------------------------------------- 2400 ! --------- List spoolqueue(s) ----------------------- 2410 ! ----------------------------------------------------- 2420 DEF FNList(Opt$) 2430 D$=Opt$ : IF Opt$<>"" GOTO 2460 2440 ; 'Spooler nr: '; 2450 INPUT LINE D$ : D$=LEFT$(D$,1) 2460 IF D$<'0' OR D$>'9' GOTO 2440 2470 IF D$>'3' GOTO 2630 ! Pseudo spooler 2480 ; #1 : ; #1 : ; #1,'List spoolqueue '+LEFT$(D$,1)+':' : ; #1 2490 ; #1,' Printfile generated by user' 2500 ; #1,' ---------------------------------' 2510 IF FNTalknet(14,7,0,ASCII(D$)-48,0,0) ; 'Net error.' : RETURN 0 2520 Nroff=PEEK(VARPTR(Buff$)+10) 2530 Active=PEEK(VARPTR(Buff$)+8) 2540 IF Nroff=0 AND Active=0 ; #1,' Queue is empty.' : ; #1. : RETURN 0. 2550 ; #1,' *PRINT'+FNTooct$(PEEK(VARPTR(Buff$)+15))+'.QP'+LEFT$(D$,1.)+' '+MID$(Buff$,18,8) 2560 Nptr=18 2570 FOR I=1 TO Nroff 2580 Nptr=Nptr+10 2590 ; #1,' PRINT'+FNTooct$(PEEK(VARPTR(Buff$)+Nptr-3))+'.QP'+LEFT$(D$,1.)+' '+MID$(Buff$,Nptr,8.) 2600 NEXT I 2610 ; #1 : ; #1,' * = current printing.' : ; #1 2620 RETURN 0 2630 ! pseudo spooler 2640 Queue=ASCII(D$)-48 2650 IF FNTalknet(14,7,0,Queue,4,0) ; 'Net error.' : RETURN 0 2660 ; #1,'List spoolqueue '+MID$(D$,1,1)+'(pseudo):' 2670 ; #1 2680 ; #1,'First element in this pseudoqueue is Print'+FNTooct$(PEEK(64965))+'.qpx' 2690 RETURN 0 2700 FNEND 2710 ! -------------------------------------------------- 2720 ! ------ Stop current printing (delete spoolfile) -- 2730 ! -------------------------------------------------- 2740 DEF FNStop(Opt$) 2750 ; #1,'Stop current printing:' : ; #1 2760 A$=Opt$ : IF Opt$<>"" GOTO 2790 2770 ; "Spooler nr: "; 2780 INPUT LINE A$ : A$=LEFT$(A$,1) 2790 IF A$<'0' OR A$>'9' GOTO 2770 2800 IF FNTalknet(14,7,ASCII(A$)-48,0,3,0) ; 'Net error.' : RETURN 0 2810 ; : ; #1,'current printing on spooler '+MID$(A$,1,1)+' stopped.' 2820 RETURN 0 2830 FNEND 2840 ! 2850 ! ----------------------------------------------------- 2860 ! ------- Clear a spoolqueue (SU only) --------------- 2870 ! ----------------------------------------------------- 2880 DEF FNClear(Opt$) 2890 ; #1,'Clear spoolqueue:' : ; #1 2900 A$=Opt$ : IF Opt$<>"" GOTO 2930 2910 ; "Spooler nr: "; 2920 INPUT LINE A$ : A$=LEFT$(A$,1) : ; 2930 IF A$<'0' OR A$>'9' GOTO 2910 2940 IF FNTalknet(14,7,ASCII(A$)-48,0,6,0) ; 'Net error.' : RETURN 0 2950 ; #1,'Spoolqueue cleared.' 2960 RETURN 0 2970 FNEND 2980 ! ------------------------------------------------------ 2990 ! ------------ Remove a spoolfile ---------------------- 3000 ! ------------------------------------------------------ 3010 DEF FNRem(Opt$) 3020 ; #1,'Remove a file from a spoolqueue:' : ; #1 3030 A$=Opt$ : IF Opt$<>"" GOTO 3090 3040 ; 'Spooler nr: '; : INPUT LINE A$ : A$=LEFT$(A$,1) 3050 IF A$<'0' OR A$>'9' OR LEN(A$)<>1 GOTO 3040 3060 ; : ; 'Pfn nr (3 octal digits): '; : INPUT LINE B$ : ; 3070 Pfn=FNOct(B$) : IF Pfn<0 GOTO 3060 3080 GOTO 3110 3090 A$=MID$(Opt$,1,1) : IF A$<'0' OR A$>'9' GOTO 3040 3100 B$=MID$(Opt$,3,3) : GOTO 3070 3110 IF FNTalknet(14,7,ASCII(A$)-48,Pfn,1,0) ; 'Some error during remove.' : RETURN 0 3120 ; #1,'File removed from queue.' : ; #1 3130 RETURN 0 3140 FNEND 3150 ! -------------------------------------------------------- 3160 ! -------- Move a spoolfile from one queue to another ---- 3170 ! -------------------------------------------------------- 3180 DEF FNMove(Opt$) 3190 ; #1 'Move file from one queue to another' : ; #1 3200 IF Opt$<>"" GOTO 3290 3210 ; 'From queue: '; : INPUT LINE A$ : A$=LEFT$(A$,1) : ; 3220 IF A$<'0' OR A$>'3' OR LEN(A$)<>1 GOTO 3210 3230 ; 'To queue: '; : INPUT LINE B$ : B$=LEFT$(B$,1) : ; 3240 IF B$<'0' OR B$>'3' GOTO 3230 3250 Frnr=ASCII(A$)-48 : Tnr=ASCII(B$)-48 3260 ; 'PFN nr (3 octal digits): '; : INPUT LINE C$ : ; 3270 Pfn=FNOct(C$) : IF Pfn<0 GOTO 3260 3280 GOTO 3320 3290 A$=MID$(Opt$,1,1) : IF A$<'0' OR A$>'3' GOTO 3210 3300 IF LEN(Opt$)<3 GOTO 3210 ELSE B$=MID$(Opt$,3,1) : IF B$<'0' OR A$>'3' GOTO 3230 3310 IF LEN(Opt$)<5 GOTO 3270 ELSE C$=MID$(Opt$,5,3) : GOTO 3270 3320 IF FNTalknet(14,7,Frnr,Pfn,2,Tnr) ; 'Error during move.' : RETURN 0 3330 ; #1,'file moved.' 3340 RETURN 0 3350 FNEND 3360 DEF FNOct(A$) 3370 IF LEN(A$)<3 RETURN -1 3380 FOR I=1 TO 3 3390 B$=MID$(A$,I,1) 3400 IF B$<'0' OR B$>'7' RETURN -1 3410 Num=Num*8+(ASCII(B$)-48) 3420 NEXT I 3430 RETURN Num 3440 FNEND 3450 DEF FNTooct$(A) 3460 A$=OCT$(A) : IF LEN(A$)=1 A$='00'+A$ 3470 IF LEN(A$)=2 A$='0'+A$ 3480 RETURN A$ 3490 FNEND 3500 ! ------------------------------------------------------- 3510 ! ----- Generate a initfile in current directory -------- 3520 ! ------------------------------------------------------- 3530 DEF FNGen 3540 ; : ; 'Generate initfile:' : ; 3550 ; ' C - Centronics.' 3560 ; ' P - Sp1.' 3570 ; ' U - 2 x Uart.' 3580 ; ' V - 2 x internal sio.' 3590 ; ' N - Old net' 3600 ; 3610 ; 'Give type: '; : INPUT LINE A$ : A$=LEFT$(A$,1) : ; 3620 IF INSTR(1,"CPUVN",A$)=0 GOTO 3610 3630 IF A$='C' OR A$='P' B$=' ' : C$=' ' : GOTO 3770 3640 IF A$<>"N" GOTO 3680 3650 ; : ; 'Give baud rate ( 8 - 19200, 9 - 38400) : '; 3660 INPUT LINE B$ : B$=LEFT$(B$,1) : ; 3670 GOTO 3770 3680 ; 'Channel A or B? '; : INPUT LINE B$ : B$=LEFT$(B$,1) : ; 3690 IF INSTR(1,"AB",B$)=0 GOTO 3680 3700 IF A$="U" C$=' ' : GOTO 3770 3710 ; : ; 'Baud rates:' : ; : ; ' 0 - 75' 3720 ; ' 1 - 110' : ; ' 2 - 300' : ; ' 3 - 300' 3730 ; ' 4 - 1200' : ; ' 5 - 2400' : ; ' 6- 4800' 3740 ; ' 7 - 9600' : ; ' 8 - 19200' 3750 ; : ; 'Give baud rate: '; : INPUT LINE C$ : C$=LEFT$(C$,1) : ; 3760 IF C$<'0' OR C$>'8' GOTO 3750 3770 ; 'Give spooler nr: '; : INPUT LINE D$ : D$=LEFT$(D$,1) : ; 3780 IF D$<'0' OR D$>'3' GOTO 3770 3790 Spool$="UFD:PRINT00"+D$+".INI" 3800 ON ERROR GOTO 3870 3810 PREPARE Spool$ AS FILE 2 3820 IF A$="N" K$=A$+B$+' ' ELSE K$=A$+B$+C$+FNForm$+' ' 3830 ; : ; 'String is: ';K$ 3840 PUT #2,K$ 3850 CLOSE 2 3860 RETURN 0 3870 ; 'File error.' : RETURN 0 3880 RETURN 0 3890 FNEND 3900 ! -------------------------------------------------- 3910 ! ----- Set remote printer baud rate (SU) ---------- 3920 ! -------------------------------------------------- 3930 DEF FNSetbaud 3940 ; : ; 'Set baud rate of remote printer' : ; 3950 ; 'Give V24 Channel(A/B) :'; : INPUT LINE A$ : A$=LEFT$(A$,1) : ; 3960 IF A$<>"A" AND A$<>"B" GOTO 3950 3970 ; : ; : ; 'Baud rates:' : ; : ; ' 0 - 75' 3980 ; ' 1 - 110' : ; ' 2 - 300' : ; ' 3 - 600' 3990 ; ' 4 - 1200' : ; ' 5 - 2400' : ; ' 6 - 4800' 4000 ; ' 7 - 9600' : ; ' 8 - 19200' 4010 ; : ; 'Give baud rate: '; : INPUT LINE B$ : B$=LEFT$(B$,1) : ; : ; 4020 IF B$<"1" OR B$>"8" GOTO 3970 4030 IF FNTalknet(14,7,ASCII(A$)-65,ASCII(B$),7,0)<>0 ; 'Central error.' 4040 RETURN 0 4050 FNEND 4060 DEF FNForm$ 4070 ; 'Do you want to specify a default formating string (y/n) ? '; 4080 INPUT LINE A$ : A$=LEFT$(A$,1) : ; : IF A$="N" OR A$="n" RETURN "VSA30D72.XXX" 4090 ; : ; 'Characters/row:' : ; : ; ' 1 - 40' 4100 ; ' 2 - 72' : ; ' 3 - 80' : ; ' 4 - 120' : ; ' 5 - 132' : ; ' 6 - 158' : ; ' 7 - 254' : ; 4110 ; 'Give chars/row (1-7) : '; : INPUT LINE A$ : A$=LEFT$(A$,1) : ; 4120 IF A$<'1' OR A$>'7' GOTO 4090 4130 Skip$="0" 4140 Chrow$=A$ : ; 'Formfeedsimulation wanted (y/n) ? '; : INPUT LINE A$ : A$=LEFT$(A$,1) : ; 4150 ; 'CRLF at end of row (y/n) ? '; : INPUT LINE B$ : B$=LEFT$(B$,1) : ; 4160 IF A$='y' AND B$='y' Mode$="D" 4170 IF A$='y' AND B$='n' Mode$="B" 4180 IF A$='n' AND B$='y' Mode$="C" 4190 IF A$='n' AND B$='n' Mode$="A" 4200 ; 'Give number of skips after each page (0-9) : '; : INPUT LINE A$ : A$=LEFT$(A$,1) : ; 4210 IF A$<"0" OR A$>"9" GOTO 4200 4220 Skip$=A$ 4230 ; : ; 'Give nr of rows / page (01-99) : '; : INPUT LINE A$ : A$=LEFT$(A$,2) : ; 4240 IF A$<'01' OR A$>'99' GOTO 4230 4250 RETURN 'VSA'+Chrow$+Skip$+Mode$+A$+".XXX" 4260 FNEND 4270 DEF FNShowform 4280 Rows$=" 40 72 80120132158254" 4290 ; #1 : ; #1,'Default formating: ' : ; #1 4300 FOR I=1 TO 4 4310 A$='print00'+CHR$(48+I-1)+'.ini' 4320 ON ERROR GOTO 4430 4330 OPEN A$ AS FILE 2 4340 ; #1,'Spooler '+CHR$(I-1+48)+': '; 4350 GET #2,A$ COUNT 20 4360 Chrr$=MID$(A$,7,1) : Skip$=MID$(A$,8,1) : Form$=MID$(A$,9,1) : Row$=MID$(A$,10,2) 4370 ; #1,'Chars/row = ';MID$(Rows$,3*(ASCII(Chrr$)-48)-2,3); 4380 IF Form$='D' OR Form$="B" ; #1,',FFsimulation'; ELSE ; #1,',FF'; 4390 IF Form$='A' OR Form$='B' ; #1,',No CRLF at rowend, '; ELSE ; #1,',CRLF at rowend, '; 4400 ; #1 'Pageskip = ';Skip$;' '; 4410 ; #1 'Rows/page = ';Row$ 4420 CLOSE 2 4430 NEXT I 4440 ON ERROR GOTO 4450 RETURN 0 4460 FNEND 4470 ! 4480 ! ********************************* 4490 ! * 4500 ! * Check if user entered from DOS or BASIC 4510 ! * 4520 DEF FNChkdos LOCAL I 4530 I=PEEK2(65302)-160 4540 WHILE I<160 : IF PEEK2(I)=-212 RETURN -1 4550 IF PEEK(I)<>13 I=I+1 : WEND 4560 RETURN 0 4570 FNEND 4580 ! 4590 ! ********************************** 4600 ! * 4610 ! * Get start parameter string (if any) 4620 ! * 4630 DEF FNStartpar$ LOCAL Cmdsp,I,Cmd$=160 4640 Cmdsp=PEEK2(65302)-160 4650 WHILE I<160 : I=I+1 : IF PEEK(Cmdsp+I-1)=44 GOTO 4680 4660 IF PEEK(Cmdsp+I-1)=13 RETURN '' ! No startpar string 4670 WEND : RETURN '' ! No startpar string 4680 IF PEEK(Cmdsp+I)=255 I=I+1 ! Skip DOS-entry flag 4690 WHILE I<160 : IF PEEK(Cmdsp+I)=13 GOTO 4720 4700 IF PEEK(Cmdsp+I)<32 OR PEEK(Cmdsp+I)>127 RETURN '' 4710 Cmd$=Cmd$+CHR$(PEEK(Cmdsp+I)) : I=I+1 : WEND 4720 RETURN Cmd$ 4730 FNEND 4740 ! 4750 ! ************************************* 4760 ! * 4770 ! * Exit to DOS or BASIC 4780 ! * 4790 DEF FNExit LOCAL A$=21,A 4800 IF FNChkdos=0 GOTO 4850 ELSE CLOSE ! We MUST close ALL files!!! 4810 A$='CMDINT SYS'+CHR$(14,255,205,27,96,216,195,3,193) 4820 A=VARPTR(A$) 4830 IF CALL(A+11,A) ; "Can't load CMDINT.SYS, press any key for RESET!"; 4840 GET A$ : IF CALL(0) REM Just a miracle would get through here... 4850 END ! End to get out of a function is ugly but... 4860 FNEND