10	 ! LOGCOR.BAS
	 ! TO MOVE 1 OR MORE RECORDS IN ".LOG" FILES TO ANOTHER POSITION
	 ! IN THE FILE
100 DIM N$[50]V,A$[56],B$[56],AN$[1]
210 INPUT "USER ";N$
215 B=1
217 CALL "SPAWNB"("PIP "+N$+".SAV="+N$+".LOG",B)
220 OPEN #3,N$+".SAV/MO/RN/SH/LN:56"
230 N=NRC(3)
235 PRINT "TOTAL RECORDS =";N
240 IF END  THEN 600
245 INPUT "LIST FROM RECORD # TO RECORD # ";R1,R2
250 FOR K=R1 TO R2 : INPUT LINE #3@K,A$ : PRINT K,A$ : NEXT K
260 INPUT "FIRST RECORD # TO MOVE ";FR
265 INPUT "LAST  RECORD # TO MOVE ";LR
270 INPUT "MOVE TO AFTER RECORD # ";IR
275 IF FR < 6 OR FR > N THEN 260
276 IF LR < 6 OR LR > N THEN 260
277 IF IR < 6 OR IR > N THEN 260
280 IF FR<IR GOTO 400		: ! MOVE TO LATER IN FILE
300				 ! MOVE TO EARLIER IN FILE
305 FOR I=1 TO LR-FR+1
310 K=FR+I-1			: ! K=RECORD WE'RE MOVING
315 INPUT LINE #3@K,A$		: ! TEMP SAVE NTH RECORD WE'RE MOVING
320 INPUT LINE #3@K-1,B$	: ! GET RECORD ONE BEFORE
325 PRINT #3@K,B$		: ! MOV RECORD ONE LATER
330 K=K-1			: ! DECREMENT POINTER
335 IF K>IR+I GOTO 320		: ! KEEP SHIFTING
340 PRINT #3@K,A$		: ! REPLACE RECORD WE SAVED
345 NEXT I
347 FOR K=R1 TO R2 : INPUT LINE #3@K,A$ : PRINT K,A$ : NEXT K
350 GOTO 500
400				 ! MOVE TO LATER IN FILE
405 FOR I=1 TO LR-FR+1
410 K=LR-I+1			: ! K=RECORD WE'RE MOVING
415 INPUT LINE #3@K,A$		: ! TEMP SAVE NTH RECORD WE'RE MOVING
420 INPUT LINE #3@K+1,B$	: ! GET RECORD ONE AFTER
425 PRINT #3@K,B$		: ! MOV RECORD UP ONE
430 K=K+1			: ! INCREMENT POINTER
435 IF K<IR-I+1 GOTO 420	: ! KEEP SHIFTING
440 PRINT #3@K,A$		: ! REPLACE RECORD WE SAVED
445 NEXT I
447 FOR K=R1 TO R2 : INPUT LINE #3@K,A$ : PRINT K,A$ : NEXT K
500 CLOSE 
505 INPUT "REPLACE RECORDS (Y OR N) ";AN$
510 IF AN$<>"Y" GOTO 217
515 INPUT "MOVE MORE RECORDS (Y OR N) ";AN$
517 IF AN$="Y" GOTO 220
520 CALL "SPAWNB"("PIP "+N$+".LOG/NV="+N$+".SAV",B)
530 CALL "SPAWNB"("PIP "+N$+".SAV;*/DE",B)
540 CALL "SPAWNB"("PIP "+N$+".LOG/PU",B)
550 EXIT 
