Commodore 1551 User Manual page 60

Table of Contents

Advertisement

To use the above program lines for the version with fixed length tields, we would
alter a few lines as follows:
10 INPUT"ENTER RECORD NUMBER";RE
200PENIS,8,IS
30 OPEN3,8,3, "MYRELFILE,L,"
+
CHR$(88)
40 BL$
= ""
SO INPUT"NAME";NA$
60 LN
=
LEN(NA$)
70 IFLEN(NA$»27 THEN SO
80 NA$
=
NA$
+
LEFT$(BL$,27 - LN)
90INPUT"STREET';SA$
100 LN
=
LEN(SA$)
110 IF LEN(SA$»27 THEN 90
120 SA$
=
SA$
+
LEFT$(BL$,27 - LN)
130 INPUT"CITY & STATE";CS$
140 LN
=
LEN(CS$)
ISO IF LEN(CS$»23 THEN 130
160 CS$
=
CS$
+
LEFT$(BL$,23 - LN)
170 INPUT"ZIP CODE" ;ZP$
180 LN
=
LEN(ZP$)
190 IF LEN(ZP$» 10 THEN 170
200 ZP$
=
ZP$
+
LEFT$(BL$, 10- LN)
210 DA$
=
NA$
+
SA$
+
CS$
+
ZP$
220 RH
=
INT(RE/2S6)
230 RL
=
RE - 2S6*RH
240 PRINT# IS, "P"
+
CHR$(96
+
3)
+
CHR$(RL)
+
CHR$(RH)
+
CHR$( I)
2S0 IFDS
=
SOTHENPRINT#3,CHR$(2SS):
GOSUB J 000:GOT0240
260 GOSUB 1000
270 PRINT#3,DA$;
280 GOSUB 1000
290 PRINT# IS, "P"
+
CHR$(96
+
3)
+
CHR$(RL)
+
CHR$(RH)
+
CHR$( I)
300 GOSUBlOOO:CLOSE3:CLOSEIS:END
1000 IFDS<20 THEN RETURN
1010 PRINT"ERROR: "DS$:CLOSE3:CLOSEIS:END
READY,
Select record number.
Open command channel.
Open the relative file
"myrelfile" , record length is 88.
27 shifted space characters
Enter fields.
Check length of each,
padding with shifted
spaces to pre-set size.
Build output data string.
Calculate record number.
Position to record number reo
If record not present, then
create it by writing to it
and reposition.
Send the data and check
for errors. Note the
added semi-colon.
Close and end.
Error checking subroutine.
If field contents vary in length, variable field lengths are often preferable. On the
other hand, if the field lengths are stable, fixed field lengths arc preferable. Fixed length
fields are also required if you want to use the optional offset parameter of the Record#
command to point at a particular byte within a record. However, one warning must be
made about using the offset this way. When any part of a record is written, DOS
S2

Advertisement

Table of Contents
loading

Table of Contents