home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Oakland CPM Archive
/
oakcpm.iso
/
cpmug
/
cpmug041.ark
/
RESIZE2.BAS
< prev
next >
Wrap
BASIC Source File
|
1984-04-29
|
4KB
|
141 lines
REM RESIZE2.BAS
VERSION = 1.01
REM 01/02/80
REM RESIZE PROGRAM FOR THE MAILLIST FILES.
REM THIS PROGRAM WAS WRITTEN BY: JAMES K. MILLS
REM P.O. BOX 94864
REM SCHAUMBURG, IL 60194
REM THE PROGRAM READS THE FLAGGED (1) RECORDS FROM \
THE FILE INTO AN ARRAY IN MEMORY, \
RE-CALCULATES THE KEY AND WRITES THE RECORD IN \
THE CORRECT PLACEMENT IN THE FILE.
REM THERE ARE DISADVANTAGES TO THIS TECHNIQUE. \
FIRST OF ALL, MAKE A BACKUP DISC BEFORE THE \
RECONFIGURATION. IF YOU HAVE A POWER FAILURE OR \
A SYSTEM FAILURE OF ANY KIND, YOUR FILES WILL \
NOT BE LOST IF YOU HAVE A BACKUP. ALSO, IF YOU \
HAVE LITTLE MEMORY, YOU WILL NOT BE ABLE TO RUN THIS \
PROGRAM SUCCESSFULLY: USE THE RE-SIZE PROGRAM \
BY WARD CHRISTENSEN WHICH \
TRANSFERS A RECORD AT A TIME FROM THE \
OLD FILE TO THE NEW FILE.
BUF.LEN = 100 :REM BUFFER 100 RECORDS IN 12K OF MEMORY
REC.LEN = 128
DIM SORT$(BUF.LEN), NAME$(BUF.LEN), ORG$(BUF.LEN), \
STREET$(BUF.LEN), CITY$(BUF.LEN), ZIP$(BUF.LEN),\
PHONE$(BUF.LEN), CLASS$(BUF.LEN), PAID$(BUF.LEN),\
TYPE$(BUF.LEN)
PRINT CHR$ (26); CHR$ (0) : REM CLEAR ADM-3A SCREEN
PRINT "RESIZE2 PROGRAM VERSION "; VERSION
PRINT "FILE NAME MAY BE ENTERED WITH A: OR B:"
PRINT
PRINT "YOU CANNOT USE THE SAME NAME FOR OLD AND NEW FILES"
PRINT
5 INPUT "CAPITAL LETTERS ONLY! OLD FILE NAME";OLD.NAME$
INPUT "CAPITAL LETTERS ONLY! NEW FILE NAME";NEW.NAME$
PRINT
IF OLD.NAME$=NEW.NAME$ THEN PRINT "USE 2 DIFFERENT FILES":\
GOTO 5
INPUT "NEW FILE NUMBER OF RECORDS";NEW.LEN
DIM R1(NEW.LEN), R2(NEW.LEN), R3(NEW.LEN), R4(NEW.LEN), \
R5(NEW.LEN), R6(NEW.LEN), R7(NEW.LEN), R8(NEW.LEN)
FILE OLD.NAME$(REC.LEN) :REM #1 = OLD FILE
FILE NEW.NAME$(REC.LEN) :REM #2 = NEW FILE
REM READ OLD RECORDS
LIVE.RECS.READ = 0 : LIVE.RECS.WRITTEN = 0
I=1 : N=0 : DONE = 0
10 PRINT "READING RECORDS FROM ";OLD.NAME$
11 IF END #1 THEN 15
READ #1,I;FLAG
IF FLAG = 0 THEN I=I+1:GOTO 11
READ #1,I;FLAG,SORT$(N),NAME$(N),ORG$(N),STREET$(N), \
CITY$(N),ZIP$(N),PHONE$(N),CLASS$(N),PAID$(N), \
TYPE$(N)
LIVE.RECS.READ=LIVE.RECS.READ+1
IF LIVE.RECS.READ/10=INT(LIVE.RECS.READ/10) THEN \
PRINT LIVE.RECS.READ;" RECORDS READ"
IF N=BUF.LEN THEN 20
I=I+1:N=N+1:GOTO 11
15 DONE = 1
20 REM WRITE RECORDS TO NEW FILE
PRINT "WRITING RECORDS TO ";NEW.NAME$
FOR A=0 TO N
GOSUB 1000
PRINT #2,KEY;1,SORT$(A),NAME$(A),ORG$(A), \
STREET$(A),CITY$(A),ZIP$(A),PHONE$(A), \
CLASS$(A),PAID$(A),TYPE$(A)
LIVE.RECS.WRITTEN=LIVE.RECS.WRITTEN+1
IF LIVE.RECS.WRITTEN/10=INT(LIVE.RECS.WRITTEN/10)\
THEN PRINT LIVE.RECS.WRITTEN; "RECORDS WRITTEN"
NEXT A
IF DONE = 0 THEN N=0:GOTO 10
PRINT
PRINT LIVE.RECS.READ; "TOTAL RECORDS READ"
PRINT LIVE.RECS.WRITTEN-1; "TOTAL RECORDS WRITTEN"
GOTO 9999
1000 KEY = 0
FOR B=1 TO LEN(NAME$(A)) STEP 2
KEY = 2*KEY + (15 AND ASC(MID$(NAME$(A),B,1))
NEXT B
KEY = KEY - NEW.LEN * INT(KEY/NEW.LEN)
KEY = INT(KEY+.1)
IF KEY <= 0 THEN KEY = 1
REM FIND OPEN SLOT IN FILE
1100 K1=INT(KEY/256)+1
IF K1=1 THEN 1110
IF K1=2 THEN 1111
IF K1=3 THEN 1112
IF K1=4 THEN 1113
IF K1=5 THEN 1114
IF K1=6 THEN 1115
IF K1=7 THEN 1116
IF K1=8 THEN 1117
PRINT:PRINT "ABANDON HOPE" :PRINT:STOP
1110 IF R1(KEY)<>0 THEN KEY=KEY+1:GOTO 1100
GOTO 1120
1111 IF R2(KEY-256)<>0 THEN KEY=KEY+1:GOTO 1100
GOTO 1120
1112 IF R3(KEY-512)<>0 THEN KEY=KEY+1:GOTO 1100
GOTO 1120
1113 IF R4(KEY-768)<>0 THEN KEY=KEY+1:GOTO 1100
GOTO 1120
1114 IF R5(KEY-1024)<>0 THEN KEY=KEY+1:GOTO 1100
GOTO 1120
1115 IF R6(KEY-1280)<>0 THEN KEY=KEY+1:GOTO 1100
GOTO 1120
1116 IF R7(KEY-1536)<>0 THEN KEY=KEY+1:GOTO 1100
GOTO 1120
1117 IF R8(KEY-1792)<>0 THEN KEY=KEY+1:GOTO 1100
1120 READ #2,KEY;FLAG
IF FLAG = 0 THEN RETURN
IF KEY > 1792 THEN R8(KEY-1792)=-1:GOTO 1150
IF KEY > 1536 THEN R7(KEY-1536)=-1:GOTO 1150
IF KEY > 1280 THEN R6(KEY-1280)=-1:GOTO 1150
IF KEY > 1024 THEN R5(KEY-1024)=-1:GOTO 1150
IF KEY > 768 THEN R4(KEY- 768)=-1:GOTO 1150
IF KEY > 512 THEN R3(KEY- 512)=-1:GOTO 1150
IF KEY > 256 THEN R2(KEY- 256)=-1:GOTO 1150
R1(KEY)=-1
1150 KEY = KEY + 1
IF KEY > NEW.LEN THEN KEY = 1
GOTO 1100
9999 CLOSE 2
CLOSE 1
END