REM > !FontsCD.Fonts

ON ERROR ON ERROR OFF: PRINT "Error: "+REPORT$+" ("+STR$ERL+")": END

SYS"Territory_Number" TO Terr%

REPEAT

CLS
PRINT"EFF 4000 PD Fonts CD installer"
PRINT"¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨"
PRINT"1. View installed fonts"
PRINT"2. Install font family"
PRINT"3. Quit"
PRINT""
PRINT"Please choose: ";
REPEAT: g$ = GET$: UNTIL g$ > "0" AND g$ < "4"
PRINT g$
PRINT

 CASE g$ OF
  WHEN "1": PROCList
  WHEN "2": PROCInstall
  WHEN "3": END
 ENDCASE

PRINT'"Press a key..."
IF GET

UNTIL 0
END


DEF PROCList
f% = OPENIN("<FontsCD$Dir>.List")
IF f% = 0 THEN PRINT"No fonts currently installed": ENDPROC
CLOSE#f%

PRINT"Installed fonts:"
OSCLI"Type <FontsCD$Dir>.List"
ENDPROC


DEF PROCInstall
INPUT"Name of font to install: "f$
f$ = FNString_Lower(f$)
l$ = LEFT$(f$, 1)

 CASE TRUE OF
  WHEN INSTR("ab", l$)   <> 0: d$ = "ab"
  WHEN INSTR("cde", l$)  <> 0: d$ = "cde"
  WHEN INSTR("fghi", l$) <> 0: d$ = "fghi"
  WHEN INSTR("jkl", l$)  <> 0: d$ = "jkl"
  WHEN INSTR("mn", l$)   <> 0: d$ = "mn"
  WHEN INSTR("opq", l$)  <> 0: d$ = "opq"
  WHEN INSTR("rs", l$)   <> 0: d$ = "rs"
  WHEN INSTR("tuvw", l$) <> 0: d$ = "tuvw"
  WHEN INSTR("xyz", l$)  <> 0: d$ = "xyz"
  OTHERWISE: PRINT"Invalid font name": ENDPROC
 ENDCASE

f% = OPENIN("<FontsCD$Dir>." + d$ + ".Fonts")
d% = FALSE
n% = 0
 REPEAT
  z$ = GET$#f%
  y$ = FNString_Lower(LEFT$(MID$(z$, 6)))
  IF (y$ = f$) OR (LEFT$(y$, LENf$ + 1) = f$ + ".") THEN PROCFound: d% = TRUE: n% += 1
 UNTIL EOF#f%
CLOSE#f%

 IF d% THEN
  SYS"OS_CLI", "FontInstall"
  PRINT STR$n% + " fonts successfully installed"
 ELSE
  PRINT"Font not found"
 ENDIF
ENDPROC


DEF PROCFound
g% = OPENUP("<FontsCD$Dir>." + d$ + ".Messages" + STR$Terr%)
PTR#g% = EXT#g%
BPUT#g%, z$
CLOSE#g%
h% = OPENUP("<FontsCD$Dir>.List")
IF h% = 0 THEN h% = OPENOUT("<FontsCD$Dir>.List")
PTR#h% = EXT#h%
BPUT#h%, LEFT$(MID$(z$, 6))
CLOSE#h%
PRINT"Installing font " + LEFT$(MID$(z$, 6)) + "‘"
ENDPROC


DEF FNString_Lower(Text$)
LOCAL Resu$, Loop%, Char%
IF Text$ = "" THEN =""
Resu$ = ""
 FOR Loop% = 1 TO LEN(Text$)
  Char% = ASC(MID$(Text$, Loop%, 1))
  IF Char% > 64 AND Char% < 91 THEN Char% += 32
  Resu$ += CHR$(Char%)
 NEXT
=Resu$