home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / utility / salvage.zip / SALVAGE.BAS < prev    next >
BASIC Source File  |  1992-08-04  |  4KB  |  175 lines

  1.  
  2. REM ======================================================
  3. REM ====                                              ====
  4. REM ====    SALVAGE version 1.53 by Andrew Chaikin    ====
  5. REM ====         Copyright (c) 1992 GeoWorks.         ====
  6. REM ====  This program may be copied and distributed  ====
  7. REM ====          but must remain unchanged.          ====
  8. REM ====    GeoWorks is not liable for any damages    ====
  9. REM ====    resulting from the use of this program.   ====
  10. REM ====                                              ====
  11. REM ======================================================
  12.  
  13. prologue:
  14. cm$ = COMMAND$
  15.  
  16. start:
  17. ON ERROR GOTO oops
  18. COLOR 15, 1
  19. CLS
  20.  
  21.  
  22. COLOR 7
  23. LOCATE 23, 1: PRINT STRING$(22, "-"); " v1.53 Copyright (c) 1992 GeoWorks "; STRING$(23, "-");
  24. LOCATE 25, 7: PRINT "This program may be copied and distributed but must remain unchanged.";
  25. LOCATE 24, 2: PRINT "GeoWorks is not liable for any damages resulting from the use of this program.";
  26. LOCATE 1, 1
  27.  
  28. COLOR 14
  29. PRINT TAB(20); "Welcome to the GeoWorks Salvage Utility."
  30. COLOR 15
  31. PRINT
  32. PRINT TAB(9); "This program creates a text file called SALVAGE.TXT, which is"
  33. PRINT TAB(10); "a copy of your file, minus all of its non-ASCII characters."
  34. PRINT TAB(17); "NOTE: Your original file will not be changed."
  35. COLOR 15
  36. PRINT
  37. PRINT TAB(14); "Type in the full DOS name of the file to be salvaged."
  38. PRINT TAB(26); "For example, FILENAME.000 ."
  39. PRINT TAB(21); "To exit this program, just hit Enter."
  40. PRINT
  41. PRINT "What file do you want to salvage? ";
  42. i$ = cm$
  43. COLOR 14
  44. IF i$ = "" THEN LINE INPUT i$ ELSE PRINT i$
  45. COLOR 15
  46.  
  47. IF i$ = "" THEN CLS : END
  48. IF LCASE$(i$) = "salvage.txt" THEN GOTO incest
  49. IF LEN(i$) > 8 AND INSTR(i$, ".") = 0 THEN GOTO invalid
  50.  
  51. 2150 OPEN "r", #1, i$, 1
  52. 2151 dummy = 0
  53. FIELD #1, 1 AS c1$
  54. li = LOF(1)
  55. chunk = li / 20
  56. IF li = 0 THEN GOTO noexist
  57.  
  58. OPEN "o", #2, "salvage.txt", 1
  59. CLOSE 2
  60.  
  61. OPEN "r", #2, "salvage.txt", 1
  62. FIELD #2, 1 AS c2$
  63. lo = 0
  64.  
  65. buh = 0
  66. gf$ = ""
  67. lewpe:
  68.   buh = buh + 1
  69.   GET #1, 32 + buh
  70.   IF ASC(c1$) = 0 THEN GOTO datzit
  71.   IF NOT (c1$ = CHR$(10) OR c1$ = CHR$(13)) THEN gf$ = gf$ + c1$
  72.   IF buh < 32 THEN GOTO lewpe
  73. datzit:
  74. SEEK #1, 1
  75.  
  76. PRINT
  77. PRINT "The PC/GEOS name of this file seems to be ";
  78. COLOR 14
  79. PRINT gf$;
  80. COLOR 15
  81. PRINT "."
  82. PRINT "Creating SALVAGE.TXT ..."
  83. PRINT "Hit <Esc> to halt the salvage process."
  84. LOCATE 17, 1: PRINT " 1 % converted. "
  85.  
  86. done = 0
  87. blah = 0
  88. prcnt = 0
  89. n = 0
  90. ik$ = ""
  91.  
  92. WHILE (ik$ <> CHR$(27)) AND (n < li)
  93.  n = n + 1:  'FOR n = 1 TO li
  94.   blah = blah + 1
  95.   IF NOT (blah > chunk) THEN GOTO eggsit
  96.   prcnt = INT(100 * n / li)
  97.   LOCATE 17, 1: PRINT prcnt; "% converted. ";
  98.   blah = 0
  99. eggsit:
  100.   GET #1, n
  101.   a = ASC(c1$)
  102.   IF NOT ((a >= 32 AND a <= 255) OR (a = 13) OR (a = 9) OR (a = 10)) THEN GOTO egress
  103.     LSET c2$ = CHR$(a)
  104.     lo = lo + 1
  105.     PUT #2, lo
  106. egress:
  107. ik$ = INKEY$
  108. WEND
  109. CLOSE
  110.  
  111. IF n = li THEN GOTO yea ELSE GOTO nay
  112.  
  113. nay:
  114. LOCATE 18, 1: PRINT "Salvage halted."
  115. PRINT
  116. GOTO dilemma
  117.  
  118. yea:
  119. LOCATE 17, 1: PRINT "100 % converted. "
  120. PRINT "Salvage complete."
  121. PRINT
  122. COLOR 31
  123. GOSUB prompt
  124. COLOR 7
  125. CLS : END
  126.  
  127. dilemma:
  128. CLEAR
  129. CLOSE
  130. PRINT "Would you like to salvage another file?"
  131. PRINT "Hit Y for yes, N for no."
  132. lupe: z$ = INPUT$(1)
  133. IF NOT (z$ = "y" OR z$ = "n" OR z$ = "Y" OR z$ = "N") THEN GOTO lupe
  134. IF z$ = "Y" OR z$ = "y" THEN GOTO start ELSE CLS : END
  135.  
  136. CLS : END
  137.  
  138. REM =============================================================
  139.  
  140. prompt:
  141. PRINT "Hit any key to quit Salvage."
  142. q$ = INPUT$(1)
  143. RETURN
  144.  
  145. oops:
  146. IF ERL <> 2150 THEN GOTO weirdone ELSE GOTO invalid
  147.  
  148. weirdone:
  149. PRINT "An unknown error has occurred."
  150. PRINT "Program terminated."
  151. GOSUB prompt
  152. CLS : END
  153.  
  154. invalid:
  155. PRINT "That's not a valid filename."
  156. PRINT
  157. GOTO dilemma
  158.  
  159. incest:
  160. PRINT "SALVAGE.TXT is the name of the output file for this program."
  161. PRINT "Thus, you cannot salvage a file named SALVAGE.TXT."
  162. PRINT "You need to exit this program and rename your file,"
  163. PRINT "and then you can come back in and salvage it."
  164. PRINT
  165. GOTO dilemma
  166.  
  167. noexist:
  168. s$ = "erase " + i$
  169. CLOSE
  170. SHELL s$
  171. PRINT "That file does not seem to exist."
  172. PRINT
  173. GOTO dilemma
  174.  
  175.