home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
utility
/
salvage.zip
/
SALVAGE.BAS
< prev
next >
Wrap
BASIC Source File
|
1992-08-04
|
4KB
|
175 lines
REM ======================================================
REM ==== ====
REM ==== SALVAGE version 1.53 by Andrew Chaikin ====
REM ==== Copyright (c) 1992 GeoWorks. ====
REM ==== This program may be copied and distributed ====
REM ==== but must remain unchanged. ====
REM ==== GeoWorks is not liable for any damages ====
REM ==== resulting from the use of this program. ====
REM ==== ====
REM ======================================================
prologue:
cm$ = COMMAND$
start:
ON ERROR GOTO oops
COLOR 15, 1
CLS
COLOR 7
LOCATE 23, 1: PRINT STRING$(22, "-"); " v1.53 Copyright (c) 1992 GeoWorks "; STRING$(23, "-");
LOCATE 25, 7: PRINT "This program may be copied and distributed but must remain unchanged.";
LOCATE 24, 2: PRINT "GeoWorks is not liable for any damages resulting from the use of this program.";
LOCATE 1, 1
COLOR 14
PRINT TAB(20); "Welcome to the GeoWorks Salvage Utility."
COLOR 15
PRINT
PRINT TAB(9); "This program creates a text file called SALVAGE.TXT, which is"
PRINT TAB(10); "a copy of your file, minus all of its non-ASCII characters."
PRINT TAB(17); "NOTE: Your original file will not be changed."
COLOR 15
PRINT
PRINT TAB(14); "Type in the full DOS name of the file to be salvaged."
PRINT TAB(26); "For example, FILENAME.000 ."
PRINT TAB(21); "To exit this program, just hit Enter."
PRINT
PRINT "What file do you want to salvage? ";
i$ = cm$
COLOR 14
IF i$ = "" THEN LINE INPUT i$ ELSE PRINT i$
COLOR 15
IF i$ = "" THEN CLS : END
IF LCASE$(i$) = "salvage.txt" THEN GOTO incest
IF LEN(i$) > 8 AND INSTR(i$, ".") = 0 THEN GOTO invalid
2150 OPEN "r", #1, i$, 1
2151 dummy = 0
FIELD #1, 1 AS c1$
li = LOF(1)
chunk = li / 20
IF li = 0 THEN GOTO noexist
OPEN "o", #2, "salvage.txt", 1
CLOSE 2
OPEN "r", #2, "salvage.txt", 1
FIELD #2, 1 AS c2$
lo = 0
buh = 0
gf$ = ""
lewpe:
buh = buh + 1
GET #1, 32 + buh
IF ASC(c1$) = 0 THEN GOTO datzit
IF NOT (c1$ = CHR$(10) OR c1$ = CHR$(13)) THEN gf$ = gf$ + c1$
IF buh < 32 THEN GOTO lewpe
datzit:
SEEK #1, 1
PRINT
PRINT "The PC/GEOS name of this file seems to be ";
COLOR 14
PRINT gf$;
COLOR 15
PRINT "."
PRINT "Creating SALVAGE.TXT ..."
PRINT "Hit <Esc> to halt the salvage process."
LOCATE 17, 1: PRINT " 1 % converted. "
done = 0
blah = 0
prcnt = 0
n = 0
ik$ = ""
WHILE (ik$ <> CHR$(27)) AND (n < li)
n = n + 1: 'FOR n = 1 TO li
blah = blah + 1
IF NOT (blah > chunk) THEN GOTO eggsit
prcnt = INT(100 * n / li)
LOCATE 17, 1: PRINT prcnt; "% converted. ";
blah = 0
eggsit:
GET #1, n
a = ASC(c1$)
IF NOT ((a >= 32 AND a <= 255) OR (a = 13) OR (a = 9) OR (a = 10)) THEN GOTO egress
LSET c2$ = CHR$(a)
lo = lo + 1
PUT #2, lo
egress:
ik$ = INKEY$
WEND
CLOSE
IF n = li THEN GOTO yea ELSE GOTO nay
nay:
LOCATE 18, 1: PRINT "Salvage halted."
PRINT
GOTO dilemma
yea:
LOCATE 17, 1: PRINT "100 % converted. "
PRINT "Salvage complete."
PRINT
COLOR 31
GOSUB prompt
COLOR 7
CLS : END
dilemma:
CLEAR
CLOSE
PRINT "Would you like to salvage another file?"
PRINT "Hit Y for yes, N for no."
lupe: z$ = INPUT$(1)
IF NOT (z$ = "y" OR z$ = "n" OR z$ = "Y" OR z$ = "N") THEN GOTO lupe
IF z$ = "Y" OR z$ = "y" THEN GOTO start ELSE CLS : END
CLS : END
REM =============================================================
prompt:
PRINT "Hit any key to quit Salvage."
q$ = INPUT$(1)
RETURN
oops:
IF ERL <> 2150 THEN GOTO weirdone ELSE GOTO invalid
weirdone:
PRINT "An unknown error has occurred."
PRINT "Program terminated."
GOSUB prompt
CLS : END
invalid:
PRINT "That's not a valid filename."
PRINT
GOTO dilemma
incest:
PRINT "SALVAGE.TXT is the name of the output file for this program."
PRINT "Thus, you cannot salvage a file named SALVAGE.TXT."
PRINT "You need to exit this program and rename your file,"
PRINT "and then you can come back in and salvage it."
PRINT
GOTO dilemma
noexist:
s$ = "erase " + i$
CLOSE
SHELL s$
PRINT "That file does not seem to exist."
PRINT
GOTO dilemma