Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why do FOR/NEXT variables end up +1 more?
#4
BASIC always behaved this way about FOR... NEXT. Since Dartmouth. Many programs depend on this "quirk".

This could cause problems with an _UNSIGNED variable used like this:
Code: (Select All)
DIM u AS _UNSIGNED INTEGER
FOR u = 10 TO 0 STEP -1
PRINT u
NEXT

Expect "u" to be -1? Read the code again. Or if it were possible in QuickBASIC to compile in debug mode it would return a runtime error. This is something that never occurred to me while using QuickBASIC or QBasic. (scratch head)
Reply


Messages In This Thread
RE: Why do FOR/NEXT variables end up +1 more? - by mnrvovrfc - 08-24-2023, 01:02 PM



Users browsing this thread: 1 Guest(s)