-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisktest.bas
80 lines (80 loc) · 2.58 KB
/
disktest.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#RetroDevStudio.MetaData.BASIC:2049,BASIC V2,uppercase,10,10
1000 REM ----------------
1010 REM -- CONSTANTS ---
1020 REM ----------------
1030 DE=8:REM DEVICE NR.
1040 RN=3:REM REL.FILE NR.
1050 DD$="0":REM DISK DRIVE NR.
1060 B1$="MY-REL-FILE":REM FILE NAME
1070 RL=144:REM RECORD LENGTH
1080 RC=31:REM RECORD COUNT
1090 Z$=CHR$(0):REM HELPER CONSTANT
1100 REM ------------------------
1110 REM --- GLOBAL VARIABLES ---
1120 REM ------------------------
1130 E0=0:E0$="":E1=0:E2=0:REM ERR.VAL.
1140 B0=0:REM NUMBER BUFFER
1142 B0$="":REM STRING BUFFER
1145 I=0:J=0:REM COUNTERS
1150 REM ------------------------
1160 GOTO1580:REM JUMP TO MAIN APP.
1170 REM ***********************
1180 REM *** READ DISK ERROR ***
1190 REM ***********************
1200 INPUT#15,E0,E0$,E1,E2:RETURN
1210 REM *******************
1220 REM *** CREATE FILE ***
1230 REM *******************
1240 OPEN RN,DE,RN,DD$+":"+B1$+",L,"+CHR$(RL)
1250 GOSUB1200:REM ERROR?
1260 IF E0=0THEN1280
1270 PRINT"CREATE: OPEN FILE ERR.: "+E0$+" "+STR$(E0):STOP
1280 PRINT#15,"P"CHR$(96+RN)CHR$(RC)Z$CHR$(RL);
1290 GOSUB1200:REM ERROR?
1300 IF E0=50THEN1320
1310 PRINT"CREATE: POS. FILE ERR.: "+E0$+" "+STR$(E0):STOP
1320 PRINT# RN,CHR$(255);:REM IS EMPTY
1330 GOSUB1200:REM ERROR?
1340 IF E0=0THEN1360
1350 PRINT"CREATE: PRINT ERR.: "+E0$+" "+STR$(E0):STOP
1360 PRINT#15,"P"CHR$(96+RN)CHR$(RC)Z$CHR$(RL);
1370 GOSUB1200:REM ERROR?
1380 IF E0=0THEN1400
1390 PRINT"CREATE: RE-POS. FILE ERR.: "+E0$+" "+STR$(E0):STOP
1400 CLOSE RN
1410 RETURN
1420 REM **************************
1430 REM *** READ RECORD NR. B0 ***
1440 REM **************************
1450 OPEN RN,DE,RN,DD$+":"+B1$+",L,"+CHR$(RL)
1460 GOSUB1200:REM ERROR?
1470 IF E0=0THEN1490
1480 PRINT"READ: OPEN FILE ERR.: "+E0$+" "+STR$(E0):STOP
1490 PRINT#15,"P"CHR$(96+RN)CHR$(B0)Z$CHR$(1);
1500 GOSUB1200:REM ERROR?
1510 IF E0=0THEN1521
1520 PRINT"READ: POS. FILE ERR.: "+E0$+" "+STR$(E0):STOP
1521 FOR I=1TO RL
1522 GET# RN,B0$
1523 GOSUB1200:REM ERROR?
1524 IF E0=0THEN1526
1525 PRINT"READ: GET FROM FILE ERR.: "+E0$+" "+STR$(E0):STOP
1526 PRINT "REC."+STR$(B0)+", BYTE "+STR$(I)+": "+STR$(ASC(B0$+Z$))
1527 IF ST<>64 THEN 1529
1528 I=RL:REM END OF RECORD REACHED
1529 NEXT I
1530 PRINT#15,"P"CHR$(96+RN)CHR$(B0)Z$CHR$(1);
1531 GOSUB1200:REM ERROR?
1532 IF E0=0THEN1540
1533 PRINT"READ: RE-POS. FILE ERR.: "+E0$+" "+STR$(E0):STOP
1540 CLOSE RN:RETURN
1550 REM -----------------
1560 REM --- MAIN APP. ---
1570 REM -----------------
1580 OPEN15,DE,15:REM OPENS CMD.CHANNEL
1590 GOSUB1240:REM CREATES REL.FILE
1591 FOR J=1TORC
1600 B0=J:GOSUB1450:REM READ FROM FILE
1601 NEXT J
1610 CLOSE15:REM CLOSES CMD.CHANNEL
1620 END