Author Topic: An improved FOR NEXT loop  (Read 6597 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: An improved FOR NEXT loop
« Reply #15 on: July 11, 2021, 08:12:25 am »
It's so basic....

'Dont forget that the for/next command stops when x becomes > ITERATION

START = 0
ITERATION = 10
County = 0

For x = START To ITERATION
    County = County + 1
Next x
Print "County="; County; " and X="; x; "    Calculated steps for next here is :"; (ITERATION - START + 1); ""


+1

@NOVARSEG you can use a While... Wend loop structure if you want that kind of loop counter index plus it's a faster loop structure.
« Last Edit: July 11, 2021, 08:28:45 am by bplus »

FellippeHeitor

  • Guest
Re: An improved FOR NEXT loop
« Reply #16 on: July 11, 2021, 08:33:06 am »
Cobalt is a purist.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: An improved FOR NEXT loop
« Reply #17 on: July 11, 2021, 08:59:29 am »
Cobalt is a purist.

I can definitely respect that :)

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: An improved FOR NEXT loop
« Reply #18 on: July 11, 2021, 11:21:20 am »
Cobalt is a purist.

@FellippeHeitor Darn Straight, and Proud of it.

Not a single GOSUB let alone a GOTO must be talk'n from Cobalt Code World again.

If you are dissing EXIT DO again that saves us from spaghetti code, at least in bplus Code World ;-))

EXIT loop is an elegant way out of a loop. I don't think that's just my opinion, I think the majority of people who complained of spaghetti code would agree that it sure beats a GOTO out of loop.

@bplus : AS a Purist, any command that causes the the code to jump out of line is spaghetti code. And there is never a need for it.
Unless we were programing in assembler which would leave no choice. But BASIC is a high enough programing language we can completely avoid it in our code.

Code: QB64: [Select]
  1. CONST TRUE = -1, FALSE = NOT TRUE
  2. A = 255
  3.  
  4. B = 0
  5.  
  6.     PRINT "hi"
  7.     B = B + 1
  8.     IF B > A THEN Flag%% = TRUE 'Will never happen because the B is an incorrect variable type here.
  9.  
  10.     IF INKEY$ = CHR$(27) THEN Flag%% = TRUE
  11.  
  12. LOOP UNTIL Flag%%
  13.  
See we do not need any GOSUB, GOTO, or EXITs here.

@Cobalt
 I made some mistakes in the code but corrected them.  FOR NEXT loops work well enough.   FOR NEXT loops must have been coded 50 years ago and they work fine but the counter variable, after exit,  is always one more than the limit (or 0 in the case of a wrap around) and it does not have to be that way.

I can't think of any good reason for it.

@NOVARSEG
The FOR\NEXT is a loop that happens while a certain variable is between 2 points(including those points). So to leave that loop the value has to be outside those points.
Code: QB64: [Select]
  1. MIN = 0 'FOR B = 0
  2. MAX = 10  'TO 10
  3. B = MIN
  4.  B = B + 1 'STEP 1
  5. LOOP WHILE  B <= MAX 'NEXT B
Granted after becoming radioactive I only have a half-life!

Offline George McGinn

  • Global Moderator
  • Forum Regular
  • Posts: 210
    • View Profile
    • Resume
Re: An improved FOR NEXT loop
« Reply #19 on: July 11, 2021, 11:43:55 am »
@bplus I disagree in part. I try to stick to modular design, and mostly a purist too, and I will use a GOTO to skip a block of code within a function or module, or to save on repeating a block of code in many IF or CASE statements. That is usually the only exception that I believe does not violate the the modular coding construct. I do this if I want to execute an endPROG: label that does some housekeeping before ending a program, rather than placing the END statement everywhere I want to end a program, or duplicating my housekeeping code many times. If more than my main logic needs to execute the endPROG, then I do make it a FUNCTION.

I use this when an IF/THEN/ELSE or CASE does not work. In other words, I may want that code executed, regardless of a tested condition, or I may want to bypass it. Rather than coding that block of code in my IF statement and again outside of it (makes for maintenance headaches) I will use a GOTO. This saves on coding when you need to replicate that code in many IF statements.

Otherwise, a program without structure with many GOTO's is spaghetti code, which I do agree with bplus. GOTO's should be used judiciously.


Quote
@bplus : AS a Purist, any command that causes the the code to jump out of line is spaghetti code. And there is never a need for it.
Unless we were programing in assembler which would leave no choice. But BASIC is a high enough programing language we can completely avoid it in our code.
____________________________________________________________________
George McGinn
Theoretical/Applied Computer Scientist
Member: IEEE, IEEE Computer Society
Technical Council on Software Engineering
IEEE Standards Association
American Association for the Advancement of Science (AAAS)

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: An improved FOR NEXT loop
« Reply #20 on: July 11, 2021, 12:00:43 pm »
OK so this is the action of the usual FOR NEXT loop

notice that things go wrong when B is a _UNSIGNED _BYTE

B has a value of 255 and then is incremented and so now equals zero. The FOR NEXT goes into an endless loop but as we know that does not happen - confused?

Hit ESCAPE key if you run the code

I suppose whoever coded the original FOR NEXT loop noticed that wrap around, so had to add extra code to prevent the endless loop.

However, the following code has only one IF condition and after exit the B counter has a value that matches A


Nothing is going wrong, except the programmer’s basic knowledge is flawed and they need to go back to school.

DIM b AS _UNSIGNED _BYTE
IF b > 255 THEN …..

Now tell me, what value you can assign to b to EVER make that IF statement a true condition so that it triggers??

b is an unsigned byte, as defined.  It’s value can ONLY be 0 to 255, and defined by the programmer.  Ergo, it’ll NEVER be greater than 255 and trigger that IF condition which exits the DO… LOOP…



So, with that part of the issue settled, let’s talk about limits of variables.

DIM b AS _UNSIGNED _BYTE
b = 255 + 1

Now, with the above, our variable b is defined as an unsigned byte and has to be in a range from 0 to 255…. Yet, we’re forcibly trying to make it hold a 2-byte value inside a 1-byte block of memory…

How does the language handle that???

You can shove a fully grown man into a child’s pair of pants, and you can’t shove a value of 256 into a single byte.  It’s just not possible.

So either you:

1) Cuss loudly, toss the pants on the floor in frustration and stop trying completely — the programming equivalent of tossing a terminating error saying “Variable Out of Bounds”, or some such, which completely halts execution…

OR:

2) You pull the pants up over as much of the ankles and toes as they can fit, and then say, “I did it!  Here’s the solution!  They fit (this much)…”

In programming, this is a simple case of OVERFLOW math.  Your return variable is 1-byte in size, so you return 1 byte.  The value 256 is stored in memory as 2 bytes (1 byte representing 1 * 256, and 1 byte representing 0).  The return value is the single byte that fits the size of your return variable type — in this case, that’s the byte representing zero, which gives a result of:

b = 255 + 1
PRINT b

b prints out “0”.

You overflowed the maximum value b could hold, so it took the bytes you designated for it and tossed out the rest.

For our pants analogy, we shaved someone’s feet and ankles into the child’s pants, and then cut the leg off above it and said, “See, it works!”



It’s not an error — it’s how the language is designed.  If you need b to become a value greater than 255, define it as an INTEGER and not an _UNSIGNED _BYTE.

Or else learn to do this:

b = 0
DO
   ….stuff
   IF b = 255 THEN
      EXIT DO
    ELSE
      b = b + 1
    END IF
LOOP

Now you exit before you overflow, and there’s no problem.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: An improved FOR NEXT loop
« Reply #21 on: July 11, 2021, 12:18:25 pm »
I’ve never had a plate of spaghetti laid out before me, with every noodle lined up in a straight row.  If someone did, would it still be called “spaghetti”, or would it be “linear noodle art”?

Spaghetti is the jumbling up and interweaving of many strands of noodles, to the point where it’s impossible to find the start of one and the end of the other…

Spaghetti code, to me, follows this same basic concept.  As long as the code reads linearly from top to bottom, it’s not “spaghetti code”.  Now, when it suddenly starts executing where you read it from top to bottom to middle to bottom to top to middle to top….   Then THAT’s spaghetti code.

DO
   EXIT DO

The above reads top to bottom, so no spaghetti code there, in my opinion.

DO
    GOTO Do_Exit
LOOP
Do_Exit:

Same…. A simple goto to move program flow down the screen.  No spaghetti twisting there.


Foo:
DO
   IF Invalid_Input GOTO Foo


Now here we have spaghetti code!  (In my opinion.). We read top, down, as  usual, and then are suddenly instructed to scroll back up and read what’s above us.  We just “twisted” the reading logic of our program.

For me, at least, as long as the code continues to be readable in a linear fashion, it’s not “spaghetti code” — even if it contains EXITs, GOTOs, or other such flow controls.  It’s when the code requires us to skip up and down in it, to read and understand it, that I’d consider it “spaghettified”.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: An improved FOR NEXT loop
« Reply #22 on: July 11, 2021, 12:36:23 pm »
Quote
Here follows what would be considered a trivial example of spaghetti code in BASIC. The program prints each of the numbers 1 to 100 to the screen along with its square. Indentation is not used to differentiate the various actions performed by the code, and the program's GOTO statements create a reliance on line numbers. The flow of execution from one area to another is harder to predict. Real-world occurrences of spaghetti code are more complex and can add greatly to a program's maintenance costs.
Code: QB64: [Select]
  1. 1 i=0
  2. 2 i=i+1
  3. 3 PRINT i; "squared=";i*i
  4. 4 IF i>=100 THEN GOTO 6
  5. 5 GOTO 2
  6. 6 PRINT "Program Completed."
  7. 7 END

Here is the same code written in a structured programming style:

Code: QB64: [Select]
  1. 1 FOR i=1 TO 100
  2. 2     PRINT i;"squared=";i*i
  3. 3 NEXT i
  4. 4 PRINT "Program Completed."
  5. 5 END

The program jumps from one area to another, but this jumping is formal and more easily predictable, because for loops and functions provide flow control whereas the goto statement encourages arbitrary flow control. Though this example is small, real world programs are composed of many lines of code and are difficult to maintain when written in a spaghetti code fashion.
Granted after becoming radioactive I only have a half-life!

Offline George McGinn

  • Global Moderator
  • Forum Regular
  • Posts: 210
    • View Profile
    • Resume
Re: An improved FOR NEXT loop
« Reply #23 on: July 11, 2021, 01:00:21 pm »
This program from the 1970's is TRUE spaghetti code:

Code: QB64: [Select]
  1. _TITLE "BASEBALL (TEXT VERSION)"
  2.  
  3. REM "BASEBALL SIMULATION PROGRAM (TEXT MODE)
  4. REM "A VERSION OF THIS PROGRAM RAN ON THE ALTAIR 8800 8K BASIC (1977)
  5. REM "WRITTEN BY JOEL LIND & KEN BIRKMAN - NYU - JULY 1973
  6. REM "STOLEN AND ENHANCED DECEMBER 1973 BY R. D. KURLAND - NYU
  7. REM "RESTOLEN AND CONVERTED TO RUN IN TECHBASIC (JULY 7, 2020) BY GEORGE MCGINN
  8. REM "CONVERTED FROM TECHBASIC TO QB64 (JULY 7, 2020) BY GEORGE MCGINN
  9.  
  10. '***************************************************
  11. ' SETUP SCREEN FORMAT & SIZE, FONT TYPE & SIZE
  12. '***************************************************
  13.  
  14. '*** Setup Screen Format and Size
  15. SCREEN _NEWIMAGE(800, 700, 32)
  16.  
  17. '*** Setup and load Font Type, Format and Size
  18. fontpath$ = "Veranda.tff"
  19. font& = _LOADFONT(fontpath$, 16, "")
  20.  
  21.  
  22. 130 DIM B(7), P$(9), W$(7), J$(8), K$(4)
  23. 140 FOR I = 1 TO 7: B(I) = 0: NEXT
  24. 150 BA = 0: T9 = 0: R9 = 0: S = 0: O = 0: B1 = 0: B2 = 0: T = 0
  25. 160 Z1 = 1: Z2 = 1
  26. 170 PRINT "WELCOME TO EBBETT'S FIELD"
  27. 180 PRINT "WHAT DO YOU WANT TO CALL YOUR TEAM ";
  28. 190 INPUT A$
  29. 200 FOR I = 1 TO 7: READ W$(I): NEXT
  30. 210 FOR I = 1 TO 9: READ P$(I): NEXT
  31. 220 FOR I = 1 TO 4: READ K$(I): NEXT
  32. 230 FOR I = 1 TO 8: READ J$(I): NEXT
  33. 240 PRINT "FINE. THE "; A$; " NEED A MANAGER. WHAT'S YOUR NAME ";
  34. 250 INPUT B$
  35. 260 PRINT "WHAT DO YOU WANT TO CALL MY TEAM, "; B$;
  36. 270 INPUT C$
  37. 280 PRINT
  38. 290 PRINT "OPENING DAY, THE "; A$; " VERSUS THE "; C$
  39. 300 PRINT
  40. 310 PRINT "LET'S FLIP A COIN. THE WINNER IS THE HOME TEAM."
  41. 320 PRINT "HEADS OR TAILS ";
  42. 330 INPUT D$: D$ = UCASE$(D$)
  43. 340 IF D$ <> "HEADS" AND D$ <> "TAILS" THEN GOTO 320
  44. 350 FOR I = 1 TO TYM
  45.    360 Y = RND(1)
  46. 370 NEXT I
  47. 380 H = 1
  48. 390 Y = RND(1)
  49. 400 Y$ = "HEADS"
  50. 410 IF Y > .5 THEN Y$ = "TAILS"
  51. 420 IF D$ = Y$ THEN 490
  52. 430 H = 0
  53. 440 PRINT "YOU LOST THE TOSS. THE "; A$; " ARE UP FIRST."
  54. 450 PRINT
  55. 460 PRINT
  56. 470 A = 0
  57. 480 GOTO 610
  58. 490 PRINT "YOU WIN THE TOSS. "; A$; " TAKE THE FIELD, AND ";
  59. 500 PRINT C$; " ARE AT BAT."
  60. 510 A = 1
  61. 520 R9 = 0
  62. 530 T = T + 1
  63. 540 IF T < 18 THEN GOSUB 5140
  64. 550 IF T < 18 THEN 710
  65. 560 IF T > 18 THEN 590
  66. 570 GOSUB 3500
  67. 580 GOTO 710
  68. 590 GOSUB 3290
  69. 600 GOTO 710
  70. 610 REM START AN INNING - WE ARE OUT ON THE FIELD
  71. 620 T = T + 1
  72. 630 R9 = 0
  73. 640 IF T < 18 THEN 690
  74. 650 IF T > 18 THEN 680
  75. 660 GOSUB 3500
  76. 670 GOTO 690
  77. 680 GOSUB 3290
  78. 690 REM IF T>2 THEN 710
  79. 700 GOSUB 5070
  80. 710 S = 0: BA = 0
  81. 720 PRINT
  82. 730 IF O = 0 THEN PRINT "NO OUTS"
  83. 740 IF O = 1 THEN PRINT "THERE IS 1 OUT"
  84. 750 IF O > 1 THEN PRINT "THERE ARE "; O; " OUTS"
  85. 760 P = B(1) + B(2) + B(3)
  86. 770 IF P <> 3 THEN 800
  87. 780 PRINT "BASES LOADED"
  88. 790 GOTO 900
  89. 800 IF P = 0 THEN 900
  90. 810 Y$ = "RUNNER ON "
  91. 820 IF P > 1 THEN Y$ = "RUNNERS ON "
  92. 830 PRINT Y$;
  93. 840 IF B(1) = 0 THEN 870
  94. 850 PRINT "FIRST";
  95. 860 IF P > 1 THEN PRINT " AND ";
  96. 870 IF B(2) = 1 THEN PRINT "SECOND";
  97. 880 IF P > 1 AND B(1) = 0 THEN PRINT " AND ";
  98. 890 IF B(3) = 1 THEN
  99.     PRINT "THIRD"
  100.     PRINT " "
  101. 900 IF A = 0 THEN 920
  102. 910 GOTO 3030
  103. 920 PRINT "BATTER UP"
  104. 930 IF BA <> 3 OR S <> 2 THEN 960
  105. 940 PRINT "FULL COUNT"
  106. 950 GOTO 970
  107. 960 IF BA > 0 OR S > 0 THEN PRINT "THE COUNT IS "; BA; " AND "; S
  108. 970 PRINT
  109. 980 IF A = 1 THEN 3030
  110. 990 PRINT "WHAT WILL YOUR BATTER DO, "; B$;
  111. 1000 INPUT C
  112. 1010 IF C > 0 AND C < 5 THEN GOTO 1050
  113. 1020 PRINT "HUH?  ";
  114. 1030 GOSUB 5070
  115. 1040 GOTO 990
  116. 1050 Y2 = RND(1)
  117. 1060 IF Y2 < .56 OR Y2 > .5625 THEN GOTO 1120
  118. 1070 PRINT "WILD PITCH!"
  119. 1080 N = 1
  120. 1090 GOSUB 3540
  121. 1100 B(1) = 0
  122. 1110 GOTO 1210
  123. 1120 IF Y2 > .772 AND Y2 < .775 THEN 4880
  124. 1130 ON C GOTO 1140, 1450, 2600, 4450, 5500
  125. 1140 C = 1
  126. 1150 GOSUB 5240
  127. 1160 IF A = 0 THEN Z1 = Z1 + 1
  128. 1170 Y = RND(1)
  129. 1180 IF BA <> 3 OR S <> 0 THEN 1200
  130. 1190 IF Y < .7 THEN GOTO 1310 ELSE GOTO 1210
  131. 1200 IF Y < .5 THEN 1310
  132. 1210 BA = BA + 1
  133. 1220 Y = INT(RND(1) * 8 + 1)
  134. 1230 IF Y = 9 THEN 1220
  135. 1240 PRINT J$(Y); " - BALL "; BA
  136. 1250 IF BA <> 4 THEN 930
  137. 1260 PRINT "WALK"
  138. 1270 GOSUB 4950
  139. 1280 Y = RND(1)
  140. 1290 GOTO 710
  141. 1300 PRINT "HIGH POP - FOUL DOWN THE "; Y$; " FIELD LINE"
  142. 1310 S = S + 1
  143. 1320 IF C = 2 OR C = 5 THEN GOTO 1370
  144. 1330 Y = INT(RND(1) * 4 + 1)
  145. 1340 IF Y = 5 THEN 1330
  146. 1350 PRINT K$(Y); ", CALLED STRIKE "; S
  147. 1360 GOTO 1380
  148. 1370 PRINT "SWINGING STRIKE "; S
  149. 1380 IF C = 5 AND S <> 3 THEN 4450
  150. 1390 IF S <> 3 THEN 930
  151. 1400 PRINT "STRUCK OUT"
  152. 1410 O = O + 1
  153. 1420 IF O = 3 THEN 2850
  154. 1430 IF C = 5 THEN 4450
  155. 1440 GOTO 710
  156. 1450 C = 2
  157. 1460 Y = INT(RND(1) * 10 + 1)
  158. 1470 IF Y = 10 THEN 1450
  159. 1480 IF A = 0 THEN Z2 = Z2 + 1
  160. 1490 IF C <> 5 THEN GOSUB 5240
  161. 1500 IF S <> 2 AND Z2 / Z1 > 7 AND A = 0 THEN 1520
  162. 1510 IF S <> 2 OR Z2 / Z1 < 25 THEN 1590
  163. 1520 Y = INT(RND(1) * 20 + 1)
  164. 1530 IF Y > 7 THEN 1550
  165. 1540 ON Y GOTO 1610, 1310, 1310, 1310, 1310, 1680, 1610
  166. 1550 IF Y > 13 THEN 1570
  167. 1560 ON Y - 7 GOTO 1680, 1310, 1740, 1850, 1740, 1850
  168. 1570 IF Y > 18 THEN 1600
  169. 1580 ON Y - 13 GOTO 1980, 1980, 2040, 2570, 1640, 2570
  170. 1590 IF Y < 3 THEN 1310
  171. 1600 ON Y - 2 GOTO 1610, 1680, 1740, 1850, 1980, 2040, 2570
  172. 1610 PRINT "FOULED INTO THE STANDS-OUT OF PLAY"
  173. 1620 IF S <> 2 THEN S = S + 1
  174. 1630 GOTO 930
  175. 1640 Y = RND(1)
  176. 1650 Y$ = "RIGHT"
  177. 1660 IF Y < .5 THEN Y$ = "LEFT"
  178. 1670 GOTO 1620
  179. 1680 Y = INT(RND(1) * 20 + 1)
  180. 1690 IF Y > 18 THEN 1720
  181. 1700 PRINT "FOULED BACK INTO THE STANDS"
  182. 1710 GOTO 1620
  183. 1720 PRINT "POPPED IT UP - CAUGHT BY CATCHER"
  184. 1730 GOTO 1410
  185. 1740 PRINT "INFIELD GROUNDER"
  186. 1750 E2 = RND(1)
  187. 1760 IF E2 < .37 OR E2 > .41 THEN 1820
  188. 1770 PRINT "1 BASE ERROR!!"
  189. 1780 N = 1
  190. 1790 C = 4
  191. 1800 GOSUB 3540
  192. 1810 GOTO 710
  193. 1820 GOSUB 4100
  194. 1830 IF O = 3 THEN 2850
  195. 1840 GOTO 710
  196. 1850 PRINT "GROUNDER - COULD BE TROUBLE - "
  197. 1860 Y = RND(1)
  198. 1870 IF Y > .75 THEN 1950
  199. 1880 Y$ = "UP THE MIDDLE"
  200. 1890 IF Y < .5 THEN Y$ = "THROUGH THE HOLE INTO RIGHT FIELD"
  201. 1900 IF Y < .25 THEN Y$ = "THROUGH THE HOLE INTO LEFT FIELD"
  202. 1910 PRINT "A SINGLE "; Y$; "!"
  203. 1920 N = 1
  204. 1930 GOSUB 3540
  205. 1940 GOTO 710
  206. 1950 PRINT "INFIELDER UP WITH IT!"
  207. 1960 GOSUB 4800
  208. 1970 IF O = 3 THEN GOTO 2850 ELSE GOTO 710
  209. 1980 Y = RND(1)
  210. 1990 Y$ = "LEFT"
  211. 2000 IF Y < .6 THEN Y$ = "CENTER"
  212. 2010 IF Y < .3 THEN Y$ = "RIGHT"
  213. 2020 PRINT "FLY-OUT TO "; Y$; " FIELD"
  214. 2030 GOTO 1410
  215. 2040 Z = RND(1)
  216. 2050 Y$ = "CENTER"
  217. 2060 IF Z < .6 THEN Y$ = "RIGHT"
  218. 2070 IF Z < .3 THEN Y$ = "LEFT"
  219. 2080 PRINT "LONG FLY TO DEEP "; Y$; " FIELD - LOOKS GOOD! "
  220. 2090 Z = RND(1)
  221. 2100 IF Z < .9 THEN 2130
  222. 2110 PRINT Y$; "FIELDER CAUGHT IT AT THE WALL!"
  223. 2120 GOTO 2180
  224. 2130 IF Z < .8 THEN 2160
  225. 2140 PRINT "A DIVING CATCH!"
  226. 2150 GOTO 2180
  227. 2160 IF Z < .7 THEN 2290
  228. 2170 PRINT Y$; "FIELDER CAUGHT IT ON THE WARNING TRACK!"
  229. 2180 O = O + 1
  230. 2190 IF O = 3 THEN 2850
  231. 2200 FOR I = 3 TO 1 STEP -1
  232.    2210 IF B(I) = 1 THEN 2240
  233. 2220 NEXT I
  234. 2230 GOTO 710
  235. 2240 B(I + 1) = B(I)
  236. 2250 B(I) = 0
  237. 2260 PRINT "LEAD RUNNER TAGS UP - AND ADVANCES 1 BASE!"
  238. 2270 GOSUB 3830
  239. 2280 GOTO 710
  240. 2290 IF Z < .5 THEN 2360
  241. 2300 PRINT "BATTER HOLDS WITH A SINGLE."
  242. 2310 N = 2
  243. 2320 GOSUB 3540
  244. 2330 B(2) = 0
  245. 2340 B(1) = 1
  246. 2350 GOTO 710
  247. 2360 IF Z < .15 THEN 2480
  248. 2370 PRINT "DOUBLE!"
  249. 2380 Y = RND(1)
  250. 2390 IF Y > .5 THEN 2430
  251. 2400 N = 2
  252. 2410 GOSUB 3540
  253. 2420 GOTO 710
  254. 2430 N = 3
  255. 2440 GOSUB 3540
  256. 2450 B(3) = 0
  257. 2460 B(2) = 1
  258. 2470 GOTO 710
  259. 2480 IF Z < .1 THEN 2530
  260. 2490 PRINT "TRIPLE!"
  261. 2500 N = 3
  262. 2510 GOSUB 3540
  263. 2520 GOTO 710
  264. 2530 PRINT "IT'S OVER THE WALL -- A H*O*M*E R*U*N!!!"
  265. 2540 N = 4
  266. 2550 GOSUB 3540
  267. 2560 GOTO 710
  268. 2570 Y = INT(RND(1) * 7 + 1)
  269. 2580 PRINT "LINED OUT TO "; P$(Y)
  270. 2590 GOTO 1410
  271. 2600 GOSUB 5240
  272. 2610 PRINT "BATTER BUNTS... "
  273. 2620 Y = RND(1)
  274. 2630 IF Y < .6 THEN 2750
  275. 2640 IF B(3) = 0 THEN 2660
  276. 2650 IF Y < .8 THEN 2830
  277. 2660 PRINT "THROWN OUT AT FIRST."
  278. 2670 O = O + 1
  279. 2680 IF O = 3 THEN 2850
  280. 2690 IF B(1) + B(2) + B(3) = 0 THEN 710
  281. 2700 PRINT "SACRIFICE - ";
  282. 2710 N = 1
  283. 2720 GOSUB 3540
  284. 2730 B(1) = 0
  285. 2740 GOTO 710
  286. 2750 IF Y < .2 THEN 2830
  287. 2760 IF Y < .4 THEN 2790
  288. 2770 PRINT "BATTER MISSES PITCH"
  289. 2780 GOTO 1310
  290. 2790 PRINT "BEATS IT OUT! SINGLE!"
  291. 2800 N = 1
  292. 2810 GOSUB 3540
  293. 2820 GOTO 710
  294. 2830 GOSUB 4100
  295. 2840 IF O <> 3 THEN 710
  296. 2850 PRINT "3 OUTS. THE SIDE IS RETIRED";
  297. 2860 I = B(1) + B(2) + B(3)
  298. 2870 IF I = 0 THEN PRINT "."
  299. 2880 IF I = 1 THEN PRINT ", LEAVING 1 MAN ON BASE"
  300. 2890 IF I > 1 THEN PRINT ", LEAVING "; I; " MEN ON BASE"
  301. 2900 PRINT
  302. 2910 PRINT
  303. 2920 PRINT "*************"
  304. 2930 D = T / 2 - INT(T / 2)
  305. 2940 PRINT "AFTER ";
  306. 2950 IF T > 1 THEN PRINT INT(T / 2); " ";
  307. 2960 IF D > .3 THEN PRINT "1/2 ";
  308. 2970 Y$ = "INNINGS"
  309. 2980 IF T < 3 THEN Y$ = "INNING"
  310. 2990 PRINT Y$; " OF PLAY, THE SCORE IS"
  311. 3000 GOSUB 3960
  312. 3010 O = 0: B(1) = 0: B(2) = 0: B(3) = 0
  313. 3020 IF A = 0 THEN GOTO 510 ELSE GOTO 470
  314. 3030 REM MY TEAM IS AT BAT
  315. 3040 Y = RND(1)
  316. 3050 IF B(1) + B(2) + B(3) = 0 THEN 3140
  317. 3060 REM IF O=2 AND S=2 AND B=3 THEN 4850
  318. 3070 IF B(3) = 1 THEN 3110
  319. 3080 IF B(2) = 0 THEN 3100
  320. 3090 IF .45 < Y AND .46 > Y THEN 4450
  321. 3100 IF .45 < Y AND .47 > Y THEN 4450
  322. 3110 IF O = 2 THEN 3140
  323. 3120 IF O < 2 AND Y < .333 AND B(3) = 1 THEN 2600
  324. 3130 IF .45 < Y AND .55 > Y THEN 2600
  325. 3140 IF S = 0 THEN 3240
  326. 3150 IF BA <> 3 THEN GOTO 3180
  327. 3160 IF Y < .6 THEN GOTO 1450
  328. 3170 GOTO 1140
  329. 3180 IF Y > .3 THEN GOTO 1450
  330. 3190 IF S <> 2 THEN GOTO 1140
  331. 3200 IF BA = 0 AND Y < .1 THEN GOTO 1140
  332. 3210 IF BA = 0 THEN GOTO 1450
  333. 3220 IF Y < .2 THEN GOTO 1140
  334. 3230 GOTO 1450
  335. 3240 IF BA = 3 THEN GOTO 3270
  336. 3250 IF Y < .6 THEN GOTO 1140
  337. 3260 GOTO 1450
  338. 3270 IF Y < .9 THEN GOTO 1140
  339. 3280 GOTO 1450
  340. 3290 IF T <> 19 THEN GOTO 3330
  341. 3300 IF R1 <> R2 THEN GOTO 3340
  342. 3310 PRINT
  343. 3320 PRINT "*** GOING INTO EXTRA INNINGS ***"
  344. 3330 IF R1 = R2 THEN RETURN
  345. 3340 IF (T - 1) / 2 <> INT(T - 1) / 2 THEN RETURN
  346. 3350 PRINT "THE BALLGAME IS OVER."
  347. 3360 PRINT "*************"
  348. 3370 PRINT "FINAL SCORE:"
  349. 3380 T9 = 1
  350. 3390 GOSUB 3960
  351. 3400 IF R1 > R2 THEN 3470
  352. 3410 PRINT "NICE TRY, "; B$
  353. 3420 PRINT "YOU SHOULD KNOW BETTER THAN TO TRY TO"
  354. 3430 PRINT "OUT-MANAGE A COMPUTER.  MAYBE BASEBALL"
  355. 3440 PRINT "JUST ISN'T YOUR SPORT...WHY DON'T YOU TRY GOLF?"
  356. 3450 REM CHAIN GOLF
  357. 3460 STOP
  358. 3470 PRINT "CONGRATULATIONS, "; B$
  359. 3480 PRINT "YOU'VE BEATEN ME, BUT I WILL HAVE MY REVENGE."
  360. 3490 STOP
  361. 3500 REM 9TH INNING
  362. 3510 IF A = 0 THEN 3530
  363. 3520 IF R2 > R1 THEN GOTO 3350 ELSE RETURN
  364. 3530 IF R1 > R2 THEN GOTO 3350 ELSE RETURN
  365. 3540 REM ADVANCE N BASES (SET N BEFORE GOSUB)
  366. 3550 N2 = B(1) + B(2) + B(3)
  367. 3560 IF C = 5 THEN N = N + 1
  368. 3570 N3 = N
  369. 3580 IF N2 = 0 THEN 3650
  370. 3590 REM FIND LAST RUNNER: MAKE SURE HE ISN‘T TRYING TO ADVANCE
  371. 3600 REM PAST HOME PLATE.
  372. 3610 FOR I = 1 TO 3
  373.    3620 IF B(I) = 1 THEN 3640
  374. 3630 NEXT I
  375. 3640 IF 4 - I < N THEN N3 = 4 - I
  376. 3650 FOR I = 3 + N TO N + 1 STEP -1
  377.    3660 B(I) = B(I - N)
  378. 3670 NEXT I
  379. 3680 B(N) = 1
  380. 3690 IF N = 1 THEN 3740
  381. 3700 FOR P = 1 TO 3
  382.    3710 IF (N - P) > 1 THEN B(N - P) = 0
  383.    3720 IF (N - P) <= 1 THEN B(1) = 0
  384. 3730 NEXT P
  385. 3740 FOR P = 1 TO 7
  386.    3750 IF P = N THEN 3780
  387. 3760 NEXT P
  388. 3770 GOTO 3830
  389. 3780 IF C = 4 OR N2 = 0 THEN 3830
  390. 3790 Y$ = "RUNNERS ADVANCE "
  391. 3800 IF N2 = 1 THEN Y$ = "RUNNER ADVANCES "
  392. 3810 PRINT Y$; N3;
  393. 3820 IF N3 = 1 THEN
  394.     PRINT " BASE"
  395.     PRINT " BASES"
  396. 3830 IF B(4) + B(5) + B(6) + B(7) = 0 THEN RETURN
  397. 3840 REM AT LEAST 1 RUN HAS SCORED.
  398. 3850 N2 = B(4) + B(5) + B(6) + B(7)
  399. 3860 IF A = 0 THEN 3890
  400. 3870 R2 = R2 + N2
  401. 3880 GOTO 3900
  402. 3890 R1 = R1 + N2
  403. 3900 B(4) = 0: B(5) = 0: B(6) = 0: B(7) = 0
  404. 3910 IF N2 = 1 THEN PRINT "** 1 RUN SCORED"
  405. 3920 IF N2 > 1 THEN PRINT "** "; N2; " RUNS SCORED"
  406. 3930 PRINT
  407. 3940 PRINT
  408. 3950 PRINT "******** NEW SCORE:"
  409. 3960 IF H = 1 THEN 4000
  410. 3970 IF LEN(A$) > LEN(C$) THEN PRINT A$; TAB(LEN(A$) + 3); R1
  411. 3980 IF LEN(A$) <= LEN(C$) THEN PRINT A$; TAB(LEN(C$) + 3); R1
  412. 3990 IF H = 1 THEN 4030
  413. 4000 IF LEN(A$) > LEN(C$) THEN PRINT C$; TAB(LEN(A$) + 3); R2
  414. 4010 IF LEN(A$) <= LEN(C$) THEN PRINT C$; TAB(LEN(C$) + 3); R2
  415. 4020 IF H = 1 THEN 3970
  416. 4030 PRINT "*************"
  417. 4040 PRINT
  418. 4050 PRINT
  419. 4060 IF T9 = 1 THEN 4090
  420. 4070 IF A = 1 AND T > 17 AND INT(T / 2) = T / 2 AND R2 > R1 THEN 3350
  421. 4080 IF A = 0 AND T > 17 AND INT(T / 2) = T / 2 AND R1 > R2 THEN 3350
  422. 4090 RETURN
  423. 4100 REM LEAD RUNNER OUT (FIELDER‘S CHOICE THEN ONE BASE ADVANCE)
  424. 4110 N = 1
  425. 4120 I = 4
  426. 4130 IF B(4) = 0 AND B(3) = 1 AND B(2) = 1 AND B(1) = 1 THEN 4220
  427. 4140 I = 3
  428. 4150 IF B(3) = 0 AND B(2) = 1 AND B(1) = 1 THEN 4220
  429. 4160 I = 2
  430. 4170 IF B(2) = 0 AND B(1) = 1 THEN 4220
  431. 4180 REM NO ONE FORCED
  432. 4190 O = O + 1
  433. 4200 PRINT "BATTER THROWN OUT"
  434. 4210 RETURN
  435. 4220 B(I - 1) = 0
  436. 4230 F = RND(1)
  437. 4240 IF O = 2 OR F > .3 THEN 4290
  438. 4250 O = O + 2
  439. 4260 PRINT "DOUBLE PLAY!"
  440. 4270 IF O = 3 THEN RETURN
  441. 4280 GOTO 4910
  442. 4290 O = O + 1
  443. 4300 PRINT "RUNNER ON BASE "; I - 1; " IS OUT ON FIELDER'S CHOICE"
  444. 4310 IF O = 3 THEN RETURN
  445. 4320 GOSUB 3540
  446. 4330 RETURN
  447. 4340 REM FORCED RUNNERS ADVANCE 1 BASE, OTHERS HOLD
  448. 4350 FOR I = 1 TO 3
  449.    4360 IF B(I) = 0 THEN 4400
  450. 4370 NEXT I
  451. 4380 N = 1
  452. 4390 GOTO 3540
  453. 4400 REM NO ONE ON BASE I
  454. 4410 FOR I2 = I TO 1 STEP -1
  455.    4420 B(I2) = 1
  456. 4430 NEXT I2
  457. 4440 RETURN
  458. 4450 REM LEAD RUNNER STEALS
  459. 4460 FOR I = 3 TO 1 STEP -1
  460.    4470 IF B(I) = 1 THEN 4510
  461. 4480 NEXT I
  462. 4490 PRINT "NO ONE ON BASE, DUMMY!"
  463. 4500 GOTO 990
  464. 4510 REM I IS LEAD RUNNER‘S BASE
  465. 4520 IF C <> 5 THEN GOSUB 5240
  466. 4530 IF RND(1) / I < .3 THEN 4680
  467. 4540 IF B(1) + B(2) + B(3) > 1 THEN 4570
  468. 4550 PRINT "RUNNER STEALS A BASE"
  469. 4560 GOTO 4580
  470. 4570 PRINT "RUNNERS STEAL A BASE"
  471. 4580 N = 1
  472. 4590 C2 = C
  473. 4600 C = 4
  474. 4610 GOSUB 3540
  475. 4620 C = C2
  476. 4630 B(1) = 0
  477. 4640 IF C = 5 AND S <> 3 THEN 930
  478. 4650 IF C = 5 THEN 710
  479. 4660 Y = RND(1)
  480. 4670 IF Y > .5 THEN GOTO 1210 ELSE GOTO 1310
  481. 4680 PRINT "RUNNER THROWN OUT STEALING"
  482. 4690 O = O + 1
  483. 4700 B(I) = 0
  484. 4710 IF O = 3 THEN GOTO 2850
  485. 4720 N = 1
  486. 4730 GOSUB 3540
  487. 4740 B(1) = 0
  488. 4750 IF C = 5 AND S <> 3 THEN GOTO 930
  489. 4760 IF C = 5 THEN GOTO 710
  490. 4770 Y = RND(1)
  491. 4780 IF BA = 3 THEN GOTO 1310
  492. 4790 IF Y > .5 THEN GOTO 1210 ELSE GOTO 1310
  493. 4800 REM RUNNERS ADVANCE ONE BASE, BATTER THROWN OUT
  494. 4810 N = 1
  495. 4820 IF O = 2 THEN 4850
  496. 4830 GOSUB 3540
  497. 4840 B(1) = 0
  498. 4850 O = O + 1
  499. 4860 PRINT "BATTER THROWN OUT"
  500. 4870 RETURN
  501. 4880 PRINT "HIT BATSMAN (OUCH!)"
  502. 4890 GOSUB 4950
  503. 4900 GOTO 710
  504. 4910 N = 1
  505. 4920 GOSUB 3540
  506. 4930 B(1) = 0
  507. 4940 RETURN
  508. 4950 REM BATTER WALKED
  509. 4960 FOR I = 1 TO 3
  510.    4970 IF B(I) = 0 THEN 5010
  511. 4980 NEXT I
  512. 4990 N = 1
  513. 5000 GOTO 3540
  514. 5010 IF I = 1 THEN 5050
  515. 5020 FOR I0 = I TO 2 STEP -1
  516.    5030 B(I0) = B(I0 - 1)
  517. 5040 NEXT I0
  518. 5050 B(1) = 1
  519. 5060 RETURN
  520. 5070 PRINT "WHEN YOUR'RE UP:"
  521. 5080 PRINT "1-BATTER TAKES PITCH"
  522. 5090 PRINT "2-BATTER SWINGS AWAY"
  523. 5100 PRINT "3-BATTER BUNTS"
  524. 5110 PRINT "4-LEAD RUNNER STEALS"
  525. 5120 REM PRINT "5-HIT AND RUN"
  526. 5130 RETURN
  527. 5140 REM PITCHING ROUTINE
  528. 5150 PRINT "YOUR PITCHER MAY THROW:"
  529. 5160 PRINT "1-FAST BALL"
  530. 5170 PRINT "2-CURVE"
  531. 5180 PRINT "3-SLIDER"
  532. 5190 PRINT "4-SINKER"
  533. 5200 PRINT "5-CHANGE-UP"
  534. 5210 PRINT "6-KNUCKLEBALL"
  535. 5220 PRINT "7-SCREWBALL"
  536. 5230 RETURN
  537. 5240 IF A = 0 THEN 5370
  538. 5250 IF R9 = 1 THEN 5300
  539. 5260 PRINT "WHAT WILL YOUR PITCHER THROW? ";
  540. 5270 INPUT W
  541. 5280 IF W < 0 THEN R9 = 1
  542. 5290 IF R9 = 0 THEN GOTO 5320 ELSE PRINT "RANDOM PITCHES FOR REST OF INNING"
  543. 5300 W = INT(RND(1) * 8 + 1)
  544. 5310 IF W = 8 THEN 5300
  545. 5320 IF W > 0 AND W < 8 THEN 5470
  546. 5330 PRINT "UH-UH, "; B$; ".  ";
  547. 5340 GOSUB 5150
  548. 5350 PRINT
  549. 5360 GOTO 5260
  550. 5370 REM I MUST SELECT A PITCH
  551. 5380 W1 = RND(1)
  552. 5390 W = 1
  553. 5400 IF W1 < .75 THEN W = 2
  554. 5410 IF W1 < .55 THEN W = 3
  555. 5420 IF W1 < .45 THEN W = 4
  556. 5430 IF W1 < .35 THEN W = 5
  557. 5440 IF W1 < .15 THEN W = 6
  558. 5450 IF W1 < .08 THEN W = 7
  559. 5460 GOTO 5470
  560. 5470 PRINT W$(W);
  561. 5480 PRINT "...";
  562. 5490 RETURN
  563. 5500 REM HIT-AND-RUN
  564. 5510 IF B(1) + B(2) + B(3) = 0 THEN 4490
  565. 5520 GOSUB 5240
  566. 5530 PRINT "HIT AND RUN!"
  567. 5540 C = 5
  568. 5550 GOTO 1460
  569. 5560 DATA FAST BALL,CURVE BALL,SLIDER,SINKER,CHANGE-UP,KNUCKLEBALL
  570. 5570 DATA SCREWBALL
  571. 5580 DATA RIGHT,LEFT,CENTER,FIRST,SECOND,THIRD,SHORTSTOP,PITCHER,CATCHER
  572. 5590 DATA RIGHT OVER THE PLATE,CAUGHT THE OUTSIDE CORNER
  573. 5600 DATA OVER THE INSIDE CORNER,OVER AT THE KNEES
  574. 5610 DATA HIGH,LOW,INSIDE,OUTSIDE,HIGH AND TIGHT,LOW AND OUTSIDE
  575. 5620 DATA LOW AND INSIDE,HIGH AND OUTSIDE
  576. 5630 END
  577.  
____________________________________________________________________
George McGinn
Theoretical/Applied Computer Scientist
Member: IEEE, IEEE Computer Society
Technical Council on Software Engineering
IEEE Standards Association
American Association for the Advancement of Science (AAAS)

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: An improved FOR NEXT loop
« Reply #24 on: July 11, 2021, 01:21:24 pm »
This program from the 1970's is TRUE spaghetti code:

Agreed.
Granted after becoming radioactive I only have a half-life!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: An improved FOR NEXT loop
« Reply #25 on: July 11, 2021, 02:09:42 pm »
All three of these will equal 10 after the loop is completed.

Code: QB64: [Select]
  1. max = 10
  2.     i = i + 1
  3. LOOP UNTIL i = max
  4.  
  5. ' Or...
  6.  
  7. max = 10
  8. FOR i = 1 TO max
  9. i = i - 1 ' Sets value of i to max.
  10.  
  11. ' Or...
  12.  
  13. max = 10
  14. FOR i = 1 TO max
  15.     IF i = max THEN EXIT FOR
  16.  

I've used all 3 if I'm concerned about the value of the i variable becoming one-extra in a FOR/NEXT loop. Really, as has been stated, it's just understanding the nature of the code.

So are the any reasonable reasons FOR NEXT increases the value of the loop variable by one upon completion? I can give one...

Code: QB64: [Select]
  1. FOR i = 1 TO 10
  2.     PRINT i
  3.  
  4. FOR j = i TO i - 1 + 10
  5.     PRINT j
  6.  
  7. PRINT: PRINT "i and j ="; i; j

So the variable FOR/NEXT increase on completion is required for progressive output, otherwise the 10th output would be repeated.

Pete

If this is food for thought, where the hell is the mustard?
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: An improved FOR NEXT loop
« Reply #26 on: July 11, 2021, 06:35:29 pm »
@Cobalt  show me your flag trick for this:
Code: QB64: [Select]
  1. Input "enter x"; x
  2. i = 1
  3.     Print "i ="; i
  4.     If x - i < 0 Then Exit Do ' avoid  print neg sqr  error
  5.     Print "SQR(input - i) ="; Sqr(x - i)
  6.     i = i + 1
  7. Loop Until i = 10
  8.  
« Last Edit: July 11, 2021, 06:44:51 pm by bplus »

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: An improved FOR NEXT loop
« Reply #27 on: July 12, 2021, 03:23:11 pm »
@bplus

you could simply:
Code: QB64: [Select]
  1. INPUT "enter x"; x
  2. i = 1
  3.  PRINT "i ="; i
  4.  IF x - i >= 0 THEN  PRINT "SQR(input - i) ="; SQR(x - i) else i = 9
  5.  i = i + 1
  6. LOOP UNTIL i = 10

Or even:
Code: QB64: [Select]
  1. INPUT "enter x"; x
  2. i = 1
  3.  PRINT "i ="; i
  4.  IF x - i < 0 THEN Flag%% = -1: i = 9
  5.  IF NOT Flag%% THEN PRINT "SQR(input - i) ="; SQR(x - i)
  6.  i = i + 1
  7. LOOP UNTIL i = 10

 here as well:
Code: QB64: [Select]
  1. INPUT "enter x"; x
  2. i = 1
  3.  PRINT "i ="; i
  4.  IF x - i < 0 THEN Flag%% = -1
  5.  IF NOT Flag%% THEN PRINT "SQR(input - i) ="; SQR(x - i)
  6.  i = i + 1
  7. LOOP UNTIL i = 10 OR Flag%%
Granted after becoming radioactive I only have a half-life!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: An improved FOR NEXT loop
« Reply #28 on: July 12, 2021, 03:32:28 pm »
Thanks Cobalt, first looks really clean without flag :)

Offline bartok

  • Newbie
  • Posts: 80
    • View Profile
Re: An improved FOR NEXT loop
« Reply #29 on: July 12, 2021, 03:58:45 pm »
NOVARSEG,
Quote
Also the counter variable stays incremented after the FOR NEXT exits. So If A = 255,   B = 256 after the exit.  There are many times when this has caused hard to trace bugs.
 

i don't think so. It is perfectly logical that the variable, when the loops ends, is incremented: the last line is "NEXT". It will be strange if it doesn't. Furtheremore, it is a fact that it is no difficult at all to rembember, and it also possible that the variable has to be incremented when the loops end. If not, it is not a problem to add a line: x = x - 1.

OldMoses,
Quote
I generally find DO...LOOP and FOR...NEXT to be nearly interchangeable, and I tend to go for DOs more often, as I've heard it said that they are somewhat faster. I try to see what gets the job done in the least amount of code, using the philosophy that the best and most reliable part is no part.

I think they are very different instead. It is true that it is often possibile to use the one or the other in many issues, but the use is very diffent. The DO-LOOP cycle, not only allows to do loops of unknown steps, but, with DO-LOOP cycles nested in pairs, it is possibile to loop only a part of a specific DO-LOOP cycle, using EXIT DO, so that many times the DO-LOOP cycle, not only often exites with EXIT DO without reaching the condition of LOOP UNTIL, LOOP WHILE, DO UNTIL, DO WHILE, but it can also loops only a part of itself.
FOR-NEXT, it is very powerfull to make arrays for math purposes.
« Last Edit: July 12, 2021, 04:03:39 pm by bartok »