Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Program Flow vs Coding Order
#3
(02-02-2026, 05:34 PM)Pete Wrote:
Code: (Select All)
GoSub pete
Print MyArray(1)
End

pete:
ReDim MyArray(10)
MyArray(1) = 5
Return

So again the program flow seems like it should handle the situation, as the Gosub statement leads us to the Redim of the array, before we print the array value. Ah, but the coding order shows that from top down, we tried to print the value before we dimensioned the array. So the fix is simple, just remember to...

Code: (Select All)
ReDim MyArray(0) ' We'll increase this value in the Gosub.
GoSub pete
Print MyArray(1)
End

pete:
ReDim MyArray(10)
MyArray(1) = 5
Return

So please share other examples where coding order effects outcome, regardless of program flow, in this thread.

Pete
You just solved an issue I was having last week where I was like "NO...this is NOT a duplicate definition !?!".  After banging my head against the wall, calling in the drywall crew to fix it, and doing it again - I just gave up.  Now I know what was happening there.  UGH !!!  

THANKS!
Reply


Messages In This Thread
Program Flow vs Coding Order - by Pete - 02-02-2026, 05:34 PM
RE: Program Flow vs Coding Order - by SMcNeill - 02-02-2026, 07:48 PM
RE: Program Flow vs Coding Order - by dano - 02-03-2026, 04:27 PM
RE: Program Flow vs Coding Order - by Pete - 02-03-2026, 05:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  personal coding challenge results James D Jarvis 4 618 06-20-2025, 03:20 PM
Last Post: James D Jarvis
  Funny Coding eoredson 10 1,775 01-01-2025, 05:09 AM
Last Post: eoredson
  Coding Efficiency SMcNeill 33 5,784 09-13-2024, 06:56 PM
Last Post: Pete
  Coding Styles Pete 33 5,518 09-09-2024, 12:46 AM
Last Post: dano
  What are your best and worst coding traits? Pete 11 2,186 11-10-2022, 04:01 AM
Last Post: JRace

Forum Jump:


Users browsing this thread: 1 Guest(s)