Sorceress

Untitled

Dec 8th, 2015
232
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CLS
  2.  
  3. bytes = 0: chars = 0
  4.  
  5. OPEN "C:\input8.txt" FOR BINARY AS #1
  6. WHILE NOT EOF(1)
  7. b$ = INPUT$(1, #1)
  8. IF b$ >= " " THEN a$ = a$ + b$
  9. IF b$ < " " OR EOF(1) THEN GOSUB ProcLine: a$ = ""
  10. WEND
  11. CLOSE #1
  12.  
  13.  
  14. END
  15.  
  16. ProcLine:
  17. bytes = bytes + LEN(a$)
  18.  
  19. IF a$ = "" THEN RETURN
  20. m$ = MID$(a$, 2, LEN(a$) - 2) 'strip endquotes
  21.  
  22. b$ = ""
  23. 'extract words
  24. FOR i = 1 TO LEN(m$)
  25. c$ = MID$(m$, i, 2)
  26. IF c$ = "\\" THEN
  27. b$ = b$ + "\"
  28. i = i + 1
  29. ELSEIF c$ = "\" + CHR$(34) THEN
  30. b$ = b$ + CHR$(34)
  31. i = i + 1
  32. ELSEIF c$ = "\x" THEN
  33. ok1 = -1: ok2 = -1
  34. h1$ = MID$(m$, i + 2, 1)
  35. h2$ = MID$(m$, i + 3, 1)
  36. IF h1$ >= "0" AND h1$ <= "9" THEN ok1 = ASC(h1$) - 48
  37. IF h1$ >= "a" AND h1$ <= "f" THEN ok1 = ASC(h1$) - 87
  38. IF h2$ >= "0" AND h2$ <= "9" THEN ok2 = ASC(h2$) - 48
  39. IF h2$ >= "a" AND h2$ <= "f" THEN ok2 = ASC(h2$) - 87
  40. IF ok1 >= 0 AND ok2 >= 0 THEN
  41. chex = ok1 * 16 + ok2
  42. b$ = b$ + CHR$(chex)
  43. i = i + 3
  44. ELSE
  45. b$ = b$ + "\"
  46. END IF
  47. ELSE
  48. b$ = b$ + MID$(m$, i, 1)
  49. END IF
  50. NEXT
  51. COLOR 15: PRINT a$; : COLOR 9: PRINT b$
  52. COLOR 8
  53. chars = chars + LEN(b$)
  54. PRINT bytes; chars; bytes - chars
  55. RETURN
RAW Paste Data