home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
SIMTEL
/
CPMUG
/
CPMUG080.ARK
/
UTILITY.STB
< prev
next >
Wrap
Text File
|
1984-04-29
|
4KB
|
151 lines
10 @"Basic Text File Manipulations."
20 @"Copyright"
30 @"David E. Trachtenbarg"
40 @"07/28/80"
50 Set 0,-1
60 Dim Command2$(0),Line$(4),Basicfile1$(13),Basicfile2$(13)
70 Dim Buffer1$(127),Buffer2$(127),Line'number$(4),Eof$(1)
80 Integer I,J,K,Rec1,Rec2,Line
85 Eof$=Chr$(26)+Chr$(27)
90 *Menu
100 @ : @
110 @"1. Create a new text file without numbers."
120 @"2. Add numbers to a text file without numbers."
140 @"3. Leave Program."
150 @
160 Input"Enter the number of your choice. ",Command$
170 If Command$="" Then Goto Menu
180 I=Val(Command$)
190 On I Goto No'numbers,Add'numbers,New
200 Goto 160
210 *No'numbers
220 Gosub Enter'input
230 If Basicfile1$="" Then Goto Menu
240 Gosub Enter'output
250 If Basicfile2$="" Then Goto Menu
260 @ : @"Deleting numbers........"
270 On Error Goto Error'report
280 On Esc Goto Escape
290 Open\1,128,1\Basicfile1$(-1)
300 Open\2,128,2\Basicfile2$(-1)
310 Rec1=0
320 Rec2=0
330 J=0
340 Repeat
350 Get\1,Rec1\Buffer1$(-1)
360 For I=0 To 127
370 Buffer2$(J,J)=Buffer1$(I,I)
380 J=J+1
390 If J=128 Then Gosub Output'record
400 If Asc(Buffer1$(I,I))=10 Then Do
410 I=I+6
420 If I>127 Then Do
430 Rec1=Rec1+1
440 Get\1,Rec1\Buffer1$(-1)
450 I=I-128
460 Enddo
470 Enddo
480 Next I
490 Rec1=Rec1+1
500 Until Iostat(1,0)>0
510 Close\1\
520 Buffer2$(J,J)=Chr$(27)
530 Put\2,Rec2\Buffer2$(-1)
540 @ Buffer2$(-1)
550 Close\2\
560 On Esc Stop
570 On Error Stop
580 Goto Menu
590 *Add'numbers
600 Gosub Enter'input
610 If Basicfile1$="" Then Goto Menu
620 Gosub Enter'output
630 If Basicfile2$="" Then Goto Menu
640 @ : @"Adding numbers......."
650 On Error Goto Error'report
660 On Esc Goto Escape
670 Open\1,128,1\Basicfile1$(-1)
680 Open\2,128,2\Basicfile2$(-1)
690 Line=0
700 Rec1=0
710 Rec2=0
720 J=0
730 Repeat
740 Get\1,Rec1\Buffer1$(-1)
750 For I=0 To 127
760 Buffer2$(J,J)=Buffer1$(I,I)
770 J=J+1
780 If J=128 Then Gosub Output'record
790 If Asc(Buffer1$(I,I))=10 Then Do
810 Line=Line+10
820 Gosub Number'line
830 For K=0 To 4
840 Buffer2$(J,J)=Line'number$(K,K)
850 J=J+1
860 If J=128 Then Gosub Output'record
870 Next K
890 Enddo
900 Next I
910 Rec1=Rec1+1
920 Until Iostat(1,0)>0
930 Close\1\
933 Buffer2$(J,J)=Chr$(27)
940 Put\2,Rec2\Buffer2$(-1)
950 @ Buffer2$(-1)
960 Close\2\
970 On Error Stop
980 On Esc Stop
990 Goto Menu
1050 *New
1060 Stop
1070 End
1080 *Enter'input
1090 @ : Input"Enter the name of the file to read from. ",Basicfile1$(-1)
1100 If Basicfile1$="" Then Return
1110 @ : @"Checking........"
1120 Set 3,0
1130 On Error Goto 1160
1140 Open\1\Basicfile1$(-1)
1150 Close\1\
1160 If Sys(3)=0 Then Return
1170 @"You cannot OPEN this file."
1180 @"Error no. ";Sys(3);" has occured."
1190 @"Enter another name or press RETURN. ";
1200 Goto Enter'input
1210 *Enter'output
1220 @ : Input"Enter the name of the file to write to. ",Basicfile2$(-1)
1230 If Basicfile2$="" Then Return
1240 @ : @"Creating file.........."
1250 Set 3,0
1260 On Error Goto 1280
1270 Erase Basicfile2$
1280 Create Basicfile2$
1290 Return
1300 *Error'report
1310 Close
1315 On Error Stop
1316 On Esc Stop
1320 @"Error no. ";Sys(3);" has occured."
1330 Input"Press RETURN to go on. ",Command$
1340 Goto Menu
1350 *Escape
1360 Close
1365 On Error Stop
1370 On Esc Stop
1380 Goto Menu
1390 *Number'line
1400 Line$=Str$(Line)
1410 K=Len(Line$)
1420 Line'number$=" "
1430 Line'number$(5-K,4)=Line$
1440 Return
1450 *Output'record
1460 Put\2,Rec2\Buffer2$(-1)
1470 @ Buffer2$(-1);
1480 Buffer2$(-1)=""
1490 Rec2=Rec2+1
1500 J=0
1510 Return