!Program JETSET - Look up Jet *.DHP & Download fonts
!
!Created by: Randall C. Haan 11/12/88
!
!SV JET font downloading utility.  This program will either use the default
!LOAD.DHP file for checking and downloading SV soft fonts or if .DHP files
!of the form HPL? are created, were ? is the printer number, it will scan
!and download to all HP printers.  If multiple HP pinters are used it is
!necessary to create JETIN?.DO files for each printer, were ? is the printer
!number, that containS the proper printer name.  ThIS program also requires
!that the ERSATZ names of LIB: [7,0] and CRT: (location of soft fonts) be
!included in the ERSATZ.INI file for proper opperation.
!
!AUXILARY FILES THAT MUST BE RESIDENT!!!
!
!JCLEAR.DO[2,2]
!
!       $D DEFAUL
!       :R
!       ; Clears the current font
!       ; and replaces the HPL1.DHP file from DSK0:[7,0]
!       LOG DSK0:[7,0]
!       :<...erasing HPL#.DHP...
!       >
!       ERASE $0.DHP
!       GOTO #$0
!       ;#DEFAUL
!       LOG $:[$P]
!       EXIT
!       ;#$0
!       COPY $0.DHP=DSK10:CLEAR.DHP[7,22]
!       LOG $:[$P]
!       :<
!       Default Font file CLEARED!
!       >
!       EXP
!
!CRT:CLEAR.DHP
!
!       (file with one blank line)
!
!CMD:JETSET.DO
!
!       :R
!       :<Creating New Font Directory
!       >
!       :S
!       LOG CRT:
!       SVDIR FONTS.DAT=*.CTR
!       LOG $:[$P]
!       :R
!       RUN BAS:JETSET
!
!LIB:HPL?.DHP (? is 1,2,3,4..ect. for each JET printer you have)
!
!       (copy of LOAD.DHP, can contain just a blank line)
!
!CMD:JETIN?.DO[2,2] (? is 1,2,3,4,...ect. for each JET printer you have)
!
!       (copy of JETINI.DO, with appropriate printer names installed)
!
!With these files in place use the command JETSET to initiate the downloading
!process.  Prompts will be supplied for every action.
!

       MAP1    LINE1,S,250     !Input line
       MAP1    FONT,S,6        !Font name
       MAP1    FILE1,S,20      !File name
       MAP1    ANS,S,1         !Answer
       MAP1    JET'NUM,B,1     !NUMBER OF PRINTERS
       MAP1    JET,S,1         !Alternate Printer Number
       MAP1    DEF'FILE,S,6    !Default HP File name
       MAP1    BLOCKS,F,6      !Number of blocks in a file
       MAP1    DF,S,6
       MAP1    CHAIN'TO,S,20   !Chain command
       MAP1    MULT,B,1        !Multiple JET flag

JET0:

PRINT TAB(-1,0);TAB(30);"JET Set"
PRINT TAB(18);"JET Downloading & Default Font Lookup"
PRINT
PRINT "I show the following fonts currently downloaded to the JET printers:"
PRINT

JET'NUM=0

JET1:

FILE1="HPL"+STR(JET'NUM+1)[1,1]+".DHP"

LOOKUP "LIB:"+FILE1,BLOCKS      !Lookup HPL's
IF BLOCKS=0 GOTO JET3           !If its not there, we must be through

JET'NUM=JET'NUM+1

OPEN#1,"LIB:"+FILE1,INPUT       !Lookup what default cartridge is in this printer
INPUT#1,DF
PRINT "JET";STR(JET'NUM)[1,1];"=";DF
CLOSE#1

GOTO JET1

JET3:

IF JET'NUM#0 GOTO JET3A                 !If no HPL's we must be using LOAD.DHP
       LOOKUP "LIB:LOAD.DHP",BLOCKS
       IF BLOCKS=0 GOTO JET3B

       OPEN#1,"LIB:LOAD.DHP",INPUT
       INPUT#1,DF
       CLOSE#1
JET3B:
       PRINT "JET1=";DF
       FONT=DF
       JET="I"
JET3A:

PRINT
PRINT "NOTE: If the printer has been turned OFF the font may need to be downloaded"
PRINT "again.  Use PRINT FONTS to examine fonts currently in printer memory."
PRINT

INPUT "WOULD YOU LIKE TO DOWNLOAD A FONT (Y/N=RET)? ";ANS
IF UCS(ANS)#"Y" GOTO JET'END

JET4:

IF JET'NUM=0 GOTO JET4A         !Used if were not using HPL's

INPUT "WHAT PRINTER # (i.e. 1,2 or 3): ";JET
IF JET<1 OR JET>JET'NUM THEN &
       PRINT "THAT PRINTER # IS NOT IN RANGE. SELECT AGAIN!": &
       GOTO JET4

JET4A:

       INPUT "Re-Download (Y/N=RET) ";ANS
       IF UCS(ANS)#"Y" GOTO JET5

       IF JET'NUM=0 GOTO JET4B

       OPEN#1,"LIB:HPL"+JET+".DHP",INPUT
       INPUT#1,FONT
       CLOSE#1

JET4B:  IF FONT="" THEN &
               PRINT:PRINT "No Font currently specified": &
               GOTO JET4

       GOTO JET7

JET5:
       INPUT "WOULD YOU LIKE TO SEE A FONT LIST? (Y/N=RET) ";ANS

       IF UCS(CHR(ASC(ANS))) <> "Y" GOTO DOWN'IT

LIST:                                   !Font listing utility
       LOOKUP "CRT:FONTS.DAT",BLOCKS
       IF BLOCKS#0 GOTO LIST1
               PRINT "Font list not found. Create?(N/Y=RET) ";
               INPUT ANS
               IF UCS(ANS)="N" GOTO JET5
               OPEN#1,"JUNK.DO",OUTPUT
                       PRINT#1,":R"
                       PRINT#1,":<Creating Font Directory...CRT: must be an ERSATZ>"
                       PRINT#1,":S"

                       PRINT#1,"LOG CRT:"
                       PRINT#1,"SVDIR FONTS.DAT=*.CTR"
                       PRINT#1,"LOG CMD:"
                       PRINT#1,"COPY JETSET.DO=$:[$P]JUNK.DO"
                       PRINT#1,"LOG $:[$P]"
                       PRINT#1,":R"
                       PRINT#1,"RUN BAS:JETSET"
               CLOSE#1
               CHAIN "JUNK.DO"

LIST1:

       OPEN#1,"CRT:FONTS.DAT",INPUT
       INPUT LINE#1,LINE1                              !FIRST LINE IS A DUD

LIST'IT:
       PRINT TAB(-1,0)
       LINES=0

LISTING:
       IF EOF(1) = 1 THEN &
               CLOSE#1: &
               GOTO DOWN'IT

       INPUT LINE#1,LINE1

       PRINT LEFT(LINE1,79)
       LINES=LINES+1
       IF LINES=20 THEN &
               INPUT "CONTINUE? (Y=RET/N) ";ANS: &
               IF UCS(CHR(ASC(ANS))) <> "N" GOTO LIST'IT &
       ELSE &
               CLOSE#1: &
               GOTO DOWN'IT

       GOTO LISTING

DOWN'IT:

       PRINT
       INPUT "Select Font: (S=SHOW/CLEAR to Clear) ";FONT
       IF UCS(FONT)="S" GOTO LIST

       FONT=LEFT(FONT+"      ",6)
       FONT=UCS(FONT)
       IF FONT#"CLEAR " GOTO F1
               PRINT "ARE YOU SURE YOU WANT TO CLEAR JET";JET[1,1];"? (Y/N=RET) ";
               ANS="":INPUT"";ANS
               IF ANS#"Y" GOTO JET0
               DEF'FILE="HPL"+JET
               IF JET'NUM=0 THEN DEF'FILE="LOAD"
               CHAIN "CMD:JCLEAR.DO "+DEF'FILE

F1:

       OPEN#1,"CRT:FONTS.DAT",INPUT

       INPUT LINE#1,LINE1                      !FIRST LINE IS A DUD

FIND'IT:

       IF EOF(1) <> 0 THEN &
               PRINT "INVALID FONT. TRY AGAIN": &
               CLOSE#1: &
               GOTO DOWN'IT

       INPUT LINE#1,LINE1

       IF LEFT(LINE1,6) <> FONT GOTO FIND'IT

       CLOSE#1

       PRINT
       A=INSTR(1,FONT," ")
       IF A#0 THEN &
               FONT=FONT[1,A-1]

       LOOKUP "CRT:"+FONT+".HPF",BLOCKS
       PRINT "The cartridge ";FONT;" is ";INT(BLOCKS*512/1000);"KBytes long. "
       IF BLOCKS>500 THEN &
               PRINT "WHOO! THAT WILL TAKE A LONG TIME TO DOWNLOAD!": &
               IF BLOCKS>970 THEN &
                       PRINT:PRINT "A FILE THAT LONG WONT FIT ON AN UN-EXPANDED PRINTER!";
       PRINT

JET7:

       ANS=""
       PRINT "Are you ready to Download ";FONT;" to JET";JET;" (Y/N=RET)? ";
       INPUT "";ANS
       IF UCS(ANS)#"Y" GOTO JET0

       PRINT TAB(-1,0);"DOWNLOADING FONT '";FONT;"' NOW."

       CHAIN'TO="CMD:JETIN"+JET+".DO "+FONT

       CHAIN CHAIN'TO

       END

JET'END:

CHAIN "EXP.LIT"