[comp.sys.tandy] data entry prog for TRS Model 100/102

alistair@ubc-bdcvax.UUCP (Alistair Blachford) (03/14/89)

At my place of work we have a program similar to ENTER on our VAX and
on our PC's.  I wrote this for people using TRS-80's in the field.  It
works very well, but it sits on 4K of RAM.  ENTER uses the status line
to advise the user of his/her options at any point -- that's my
excuse for the absence of accompanying documentation.

I'll point out that prompted, type-checked data entry using a program
like this is MUCH faster, and more goof-proof, than is free-form data
entry using an editor.

Hope it's handy!
Alistair

1 ' ENTER is for prompted entry of data, field by field within each
2 ' record (line), on a TRS-80 Model 100/102. It checks input
3 ' according to the data types you define along with the prompts.
4 ' Pass it along to anyone who might want to use it.  If you find
5 ' that ENTER saves you time, please consider sending me $5-10 for
6 ' *my* time.  Then I'll notify you of any improvements and bug
7 ' fixes. I welcome suggestions and bug-reports, too. Thanks,
8 ' Alistair Blachford
9 ' 4460 West 11th Ave.
10 'Vancouver, BC Canada V6T 1W5
11 ' alistair@bdc.ubc.ca
12 MAXFILES=2
13 DIMSC$(4),RP$(5)
14 SC$(0)=""
15 SC$(1)="0123456789+-"
16 SC$(2)="0123456789+-Ee."
17 PRINTCHR$(27)+CHR$(81);
18 CLS
19 'FORI=80TO95:PRINT@I," Alistair' s ":NEXTI" 
20 FORI=194TO178STEP-1:PRINT@I,"ENTER ":NEXTI
21 FORI=1TO200:NEXTI
22 PRINT@178,CHR$(27)+CHR$(112)+"ENTER";
23 FORI=1TO200:NEXTI
24 PRINT@178,CHR$(27)+CHR$(113)+"ENTER"+CHR$(10)
25 FORI=1TO200:NEXTI
26 PRINTCHR$(27)+CHR$(80);
27 ONKEYGOSUB,,,,,,,68
28 KEY(8)ON
29 ONERRORGOTO69
30 PRINT"prompt file: ";:GOSUB79
31 IFNM%=1THEN30
32 PF$=FN$
33 IFFF%=1THENGOSUB86
34 OPENFN$FORINPUTAS1
35 PRINT"output file: ";:GOSUB79
36 IFNM%=1THEN35
37 IFFF%=1THEN43
38 PRINT"Output file exists already."
39 PRINT"OK to append to it? (y/n): ";:LINEINPUTYN$
40 IFYN$="y"ORYN$="Y"THEN42
41 PRINT:PRINT"new ";:GOTO35
42 CLS:PRINT@120,"Appending to '";FN$;"' ..."
43 OPENFN$FORAPPENDAS2:CLS
44 LINEINPUT#1,FS$
45 LINEINPUT#1,LN$
46 IFLEFT$(LN$,1)><"#"THENGOTO49
47 SC$(3)=MID$(LN$,2)
48 GOTO45
49 C%=INSTR(LN$,":")
50 P$=MID$(LN$,2,C%-2)
51 YN$=MID$(LN$,C%+1,1)
52 I%=VAL(MID$(LN$,C%+2))
53 GOSUB142
54 IN$=""
55 IFYN$="R"THENIN$=RP$(I%)
56 PRINTP$+": "+IN$;
57 IFYN$<>"R"THENCS$=SC$(I%)
58 GOSUB170
59 PRINT
60 PRINT#2,IN$;
61 IFEOF(1)GOTO64
62 PRINT#2,FS$;
63 GOTO45
64 PRINT:PRINT#2,""
65 CLOSE#1
66 OPENPF$FORINPUTAS1
67 GOTO44
68 CLOSE:MENU
69 '
70 IFERR<>52THEN73
71 FF%=1
72 RESUMENEXT
73 IFERR<>55THEN77
74 NM%=1
75 BEEP:PRINT"badfilename"+CHR$(13)+CHR$(27)+CHR$(65);
76 RESUMENEXT
77 PRINT"OOPS -- Error";ERR;"in line";ERL
78 STOP
79 '
80 LINEINPUTFN$
81 FF%=0:NM%=0
82 OPENFN$FORINPUTAS2
83 CLOSE#2
84 RETURN
85 '
86 PRINT:PRINT"Prompt file '";PF$;"' does not exist."
87 PRINT"Enter substitute name, or just hit"
88 PRINT"<enter>to procede with creation"
89 PRINT"of '";PF$"': ";:LINEINPUTAF$
90 IFAF$=""GOTO92
91 PF$=AF$:RESUME
92 CLS:PRINTCHR$(239)+" Creating prompt file '";PF$;"' ... "+CHR$(239)
93 OPENPF$FOROUTPUTAS1
94 SL$=" Defaults to<space>"
95 GOSUB161:PRINT
96 PRINT"field separator: ";:LINEINPUTF$
97 F$=F$+" "
98 PRINT#1,LEFT$(F$,1)
99 N%=1:RN%=0
100 SL$=" enter . as prompt to end"
101 GOSUB161:PRINT""
102 PRINT"prompt"+STR$(N%)+": ";:LINEINPUTP$
103 IFP$="."THENGOTO134
104 SL$="Text Integer Float User-defined  Repeat"
105 GOSUB161
106 PRINT"data type (TIFUR): ";
107 YN$="Y":CS$="TtIiFfUuRr"
108 GOSUB170:IFLEN(IN$)<>0THEN110
109 BEEP:GOTO108
110 PRINT:DT$=LEFT$(IN$,1)
111 TS$="":SC$=""
112 IFDT$="T"ORDT$="t"THENTS$="N0"
113 IFDT$="I"ORDT$="i"THENTS$="Y1"
114 IFDT$="F"ORDT$="f"THENTS$="Y2"
115 IFDT$="R"ORDT$="r"THENTS$="R"+MID$(STR$(RN%),2)
116 IFDT$="R"ORDT$="r"THENRN%=RN%+1
117 IFTS$><""THENGOTO132
118 SL$=" Acceptables  Unacceptables "
119 GOSUB161
120 PRINT:PRINT"User-defined type. Which characters"
121 PRINT"would you like to specify? (AU): ";
122 YN$="Y":CS$="AaUu"
123 GOSUB170:IFLEN(IN$)=0THEN123
124 IN$=LEFT$(IN$,1)
125 IFIN$="A"ORIN$="a"THENTS$="Y3"
126 IFIN$="U"ORIN$="u"THENTS$="N3"
127 IFTS$="Y3"THENSL$=" Acceptables "ELSESL$=" UNacceptables "
128 GOSUB161
129 PRINT:PRINT"Enter string of characters: ";
130 LINEINPUTSC$
131 PRINT#1,"#"+SC$
132 PRINT#1," "+P$+":"+TS$
133 N%=N%+1:GOTO100
134 CLOSE#1
135 CLS:PRINTCHR$(239)+" Prompt file '";PF$;"' complete "+CHR$(239):PRINT
136 CP%=CSRLIN
137 PRINTCHR$(27)+CHR$(85);
138 PRINT@280,CHR$(27)+CHR$(108);
139 PRINT@CP%*40,"";
140 RETURN
141 '
142 CP%=CSRLIN
143 PRINTCHR$(27)+CHR$(81);
144 IFYN$<>"R"GOTO146
145 SL$="AUTO-REPEAT  "+CHR$(155)+"kills entry":GOTO151
146 ONI%+1GOTO147,148,149,150
147 SL$="TEXT":GOTO151
148 SL$="INTEGER":GOTO151
149 SL$="FLOAT":GOTO151
150 IFYN$="Y"THENSL$="any of:"ELSESL$="none of:"
151 IFINSTR(SL$,"T")=0THENSL$=SL$+SC$(3)
152 PRINTCHR$(27)+CHR$(85);
153 PRINT@280,CHR$(27)+CHR$(108);
154 IFLEN(SL$)<=28THENPRINT@307,CHR$(239);" F8 to quit";
155 PRINT@280,LEFT$(SL$,40);
156 PRINTCHR$(27)+CHR$(84);
157 PRINTCHR$(27)+CHR$(80);
158 PRINT@CP%*40,"";
159 RETURN
160 '
161 CP%=CSRLIN
162 PRINTCHR$(27)+CHR$(85);
163 PRINT@280,CHR$(27)+CHR$(108);
164 PRINTCHR$(27)+CHR$(112);
165 PRINT@280,LEFT$(SL$,39);
166 PRINTCHR$(27)+CHR$(113);
167 PRINTCHR$(27)+CHR$(84);
168 PRINT@CP%*40,"";
169 RETURN
170 '
171 IFYN$="R"THENIN$=RP$(I%)ELSEIN$=""
172 K$=INKEY$:IFK$=""THEN172
173 IFK$<>CHR$(29)THEN179
174 FORXX%=0TOLEN(IN$)
175 PRINTCHR$(27)+CHR$(68);
176 NEXTXX%
177 PRINTCHR$(27)+CHR$(75)+" ";
178 IN$=""
179 IFK$<>CHR$(13)THEN183
180 IFYN$="R"THENRP$(I%)=IN$
181 PRINTCHR$(27)+CHR$(75);
182 RETURN
183 IFK$<>CHR$(8)THEN188
184 IFLEN(IN$)>0THEN186
185 BEEP:GOTO172
186 IN$=LEFT$(IN$,LEN(IN$)-1)
187 PRINTCHR$(8);:GOTO172
188 IFASC(K$)<32ORASC(K$)>126THEN192
189 IFYN$="Y"ANDINSTR(CS$,K$)>0THEN194
190 IFYN$="N"ANDINSTR(CS$,K$)=0THEN194
191 IFYN$="R"GOTO194
192 IFASC(K$)<>29THENBEEP
193 GOTO172
194 IN$=IN$+K$:PRINTK$;:GOTO172