The user is prompted for a file name based on ProDOS or DOS 3.3 rules.
A default file name is provided. Control-C catalogs the disk. ESC exits.
Blank entry is refused. In ProDOS, lowercase is converted to uppercase.

Note: you will need to have NuInput loaded for this code to work

100 ST$ = "" : REM [only necessary before the first CALL 250 in program]

105 DE$ = "MY.SAVED.GAME" : REM default file name

110 KC$ = "C[" : REM enable control-C and ESC for submit

115 POKE 254,(128+32+2) : REM options:no break, lower-to-upper, no blank

120 KL$ = ".ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" : REM ok ProDOS chars

125 IF (PEEK(48896)=76) THEN CT$ = "CAT" : NL = 15 : GOTO 140 : REM PDOS

130 NL = 30 : CT$ = "CATALOG" : POKE 254,(128+2) : REM DOS 3.3

135 KL$ = KL$+CHR$(34)+"!#$%&'()*+-/:;<=>?@[\]^_`{|}~ " : REM DOS 3.3

140 POKE 253,NL : REM maximum filename length

150 PRINT "ENTER FILE NAME: "; : CALL 250 : REM user prompt & NuInput

155 IF (PEEK(8)=27) THEN PRINT : END : REM if ESC was typed, quit

160 DE$ = ST$ : REM set default entry to typed text in case of reprompt

165 IF (PEEK(8)<>3) THEN GOTO 175 : REM if not ctrl-C, continue

170 PRINT : PRINT : PRINT CHR$(4);CT$ : GOTO 150 : REM ctrl-C, catalog

175 IF ( ASC(LEFT$(ST$,1)) >= ASC("@") ) THEN GOTO 185 : REM is name ok?

180 HTAB 1 : GOTO 150 : REM illegal first character, prompt again

185 PRINT : PRINT : PRINT "ST$ IS NOW: ";ST$

200 REM program continues here with file name in ST$
