home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d121 / basicstrip.lha / BasicStrip / BS.ReadMe < prev    next >
Text File  |  1987-12-31  |  4KB  |  137 lines

  1. STRIP BASIC
  2.  
  3. This is a shareware program copyright 1987 by George Trepal.  It's OK to distribute this program free, or in the case of computer clubs or similar groups to charge a small copying fee, but it's not legal to sell it.  If you feel it's useful enough to be worth something then I'll happily accept contributions.  George Trepal, 2650 Alturas Road, Bartow, Florida  33830  USA.
  4.  
  5.      This program helps to convert Basic programs written on other computers to AmigaBASIC.  It deletes line numbers, puts in its own jump labels, and tries to format the result as a structured program.  It also breaks down lines with multiple commands.  Really weird coding will confuse it but it works about 99% of the time and can save you lots of time and energy.
  6.      To use it the alien Basic has to be in the form of an ASCII file.  Most computers let you save Basic as ASCII with no hassle.  There are a few you need to be creative about such as the Commodore 64.
  7.      Next you have to see if all the commands are run together.  Some Basics allow that and you'll see something like:
  8.  
  9. 100 FORJ=1TO50:PRINT"POO":NEXT  (not a space in the line)
  10.  
  11. AmigaBasic can't handle stuff like this.  All Basic Command words have to be set off with spaces.  Use the global change of a word processor, editor, microemacs, or whatever to fix the problem.  You'll now have:
  12.  
  13. 100 FOR J=1 TO 50:PRINT "POO":NEXT
  14.  
  15.      Now load the program into AmigaBasic then save it from AmigaBasic by SAVE "filename",a
  16.      What this does is capitalize all the command words so my program can find them.  Saving with comma A forces the computer to write an ASCII file.
  17.  
  18.      Finally it's time to run my program.  Look at the before and after examples below.
  19.  
  20. (By the way, this code does nothing it's just a test fragment.)
  21.  
  22. BEFORE:
  23.  
  24. 100 FOR j = 1 TO 5: PRINT  "Whee":NEXT
  25. 110 IF x = 3 THEN y=3:p=4:G=4:GOTO 200
  26. 115 G = 1
  27. 120 q = Z:r = M:l=6: GOTO 1100
  28. 130 GOSUB 500
  29. 140 ON x GOTO 200, 300, 400
  30. 200 PRINT  "200"
  31. 210 END
  32. 220 :
  33. 300 PRINT  "300"
  34. 310 END
  35. 400 PRINT  "400"
  36. 410 END
  37. 500 INPUT x
  38. 510 RETURN
  39. 610 IF p = 2 THEN l = 7: p = 3: GOSUB 300
  40. 620 GOSUB 1100
  41. 630 IF t = 5 THEN 300
  42. 640 IF t = 6 THEN l = 5
  43. 1100 IF x = 1 THEN FOR j = 1 TO 6: p = q: NEXT
  44.  
  45.  
  46. Here's what it looks like after it's been run through the mill.
  47.  
  48. AFTER:
  49.  
  50.   FOR j = 1 TO 5
  51.     PRINT  "Whee"
  52.   NEXT
  53.     IF x = 3 THEN
  54.       y=3
  55.       p=4
  56.       G=4
  57.       GOTO Jump1
  58.     END IF
  59.     G = 1
  60.     q = Z
  61.     r = M
  62.     l=6
  63.     GOTO Jump5
  64.     GOSUB Jump4
  65.     ON x GOTO Jump1, Jump2, Jump3
  66.    
  67.   Jump1:
  68.     PRINT  "200"
  69.     END
  70.    
  71.    
  72.   Jump2:
  73.     PRINT  "300"
  74.     END
  75.    
  76.   Jump3:
  77.     PRINT  "400"
  78.     END
  79.    
  80.   Jump4:
  81.     INPUT x
  82.     RETURN
  83.     IF p = 2 THEN
  84.       l = 7
  85.       p = 3
  86.       GOSUB Jump2
  87.     END IF
  88.     GOSUB Jump5
  89.     IF t = 5 THEN Jump2
  90.     IF t = 6 THEN l = 5
  91.    
  92.   Jump5:
  93.     IF x = 1 THEN
  94.       FOR j = 1 TO 6
  95.         p = q
  96.       NEXT
  97.     END IF
  98.   
  99.      There's a quirk of AmigaBasic you have to watch out for.  Consider this alien Basic fragment:
  100.  
  101. 100 FOR J = 1 TO 20
  102. 110 IF L > P THEN GOTO 130
  103. 120 R = S
  104. 130 R = T
  105. 140 NEXT
  106.  
  107. When my program gets hold of this it becomes
  108.  
  109.   FOR J = 1 TO 20
  110.     IF L > P THEN GOTO Jump1
  111.     R = S
  112.  
  113.   Jump1:
  114.     R = T
  115.   NEXT
  116.  
  117.      It looks nice but AmigaBasic won't run it.  It won't allow a label in a FOR-NEXT loop and you'll next a For Without Next or Next Without For error.
  118.      The solution?  Clean up the code.
  119.  
  120.   FOR J = 1 TO 20
  121.     IF L > P THEN R = S ELSE R = T
  122.   NEXT
  123.  
  124.  
  125.      In case you need to get ASCII from a C-64 here's how.  Load the Basic program in the C-64.  To save it as ASCII you tell the computer:
  126.  
  127. OPEN 8,8,8,"filename,S,W": CMD 8: LIST
  128.  
  129. then after the drive no longer makes noise you tell it:
  130.  
  131. PRINT#8," ": CLOSE 8
  132.  
  133.      The first part of the first line opens a sequential file to be output to device number 8 (the disk drive.)  The second part directs all output to device number 8.  When you tell it to list the list, in ASCII, goes to the drive instead of the screen or printer.
  134.      The first part of the second line clears the drive's buffer thus making sure you have all your file on disk.
  135.      Complex but it works.  If a C-64 can be made to output ASCII files I think any computer can be made to output them.
  136.  
  137.