12-30-2024, 04:39 AM
I'm Sorry! LOL because I had to post this funny code:
Erik.
Code: (Select All)
i = 10
For x(i) = 1 to 10
Print x(i)
Next
Funny Coding
|
12-30-2024, 04:39 AM
I'm Sorry! LOL because I had to post this funny code:
Code: (Select All) i = 10
I don't think that's even allowed. You can't use an array like that in a FOR loop. At least, I don't think you can.
(Moved thread as this isn't any sort of utility at all. Just a basic observation.)
12-30-2024, 06:31 AM
nice, this kinda thing often happens with pointer confusion in C, ie address vs destination
12-30-2024, 06:49 AM
(12-30-2024, 04:46 AM)SMcNeill Wrote: I don't think that's even allowed. You can't use an array like that in a FOR loop. At least, I don't think you can. hi SMcNeill. This is allowed, please try it and let me know what you think. Code: (Select All)
Thanks.
12-30-2024, 09:54 PM
@gaslouk - Take a closer look!
Code: (Select All)
Or try this:
Code: (Select All)
If it creates an error then comment it out..
Guys, why are you making it seem like this is complicated?? This is VERY simple and easy to understand. Let me break it down to you.
Code: (Select All)
Now, the above works. WHY does it work?? WHY don't we have an ever increasing milepost with the change to a(10) increasing by a power of 10 every pass?? Because the START and FINISH value is calculated *ONCE* when the FOR loop is called and it doesn't change after that point!! What the above basically has is the equivalent of: FOR x = 1 TO 10 a(10) = a(10) * 10 NEXT Now, someone.... *ANYONE*... give me one good reason why the hell that wouldn't work? Why would anyone expect an error to occur at this point??? You CAN use array values for the START and FINISH portion of your FOR statement. Hell, you can even use it for the STEP portion of your statement as that value doesn't change after the FOR loop is initialized!! Code: (Select All)
Now, the above is NOT possible. It's plain silly to think that it might be possible. Anyone who looks at this and says, "Gosh! I want to do that!", needs to hang up their programming license and go take up needlepoint.......... Someone explain to me exactly HOW that is supposed to work?? a(i) *HAS*: to change values *during* the loop. It's our counter. It's the whole thing that tracks how long we're doing the loop for. So, to start with, we make a loop with a counter called a(0) and that counter needs to count from 1 to 10, incrementing by one... and then... we throw away that counter, swap out to a different one that has never been created at all, and we try and do a NEXT a(1)... How the heck does anyone expect to NEXT a(1) in a FOR a(0) loop??? Do you guys not see how these are fundamentally different beasts? FOR Counter_Variable = Start TO Finish STEP Stepper Start can be an array, because it's only calculated ONCE at the loop initialization. Finish can be an array, because it's only calculated ONCE at the loop initialization. Stepper can be an array, because it's only calculated ONCE at the loop initialization. Counter_Variable... can NOT be an array as you can't just swap out your counter all willy nilly like that. Let's break this down to an oral exercise: Steve says, "Okay, Eric count from 1 to 10, increasing by 1 every time I tell you next." Eric says, "One!" Steve says, "Next Pete!" Pete says, "Potatoe!!" Steve says, "Next bplus!" ??? ??? ??? ??? When does Eric ever finish counting to 10? Or Pete get to Rhubarb? What the heck does bplus even start at? Pi? How the heck can anyone expect to change the variable they're counting by in the middle of a FOR loop?? That just doesn't work, and it's the reason why an array is an unsupported type for the counter_variable. You can mess around with arrays and UDTs and everything else all you want with the START, FINISH, STEPPER portion. You just can't up and use an array in the COUNTER portion of a FOR loop. This isn't complicated. Why's everyone seem to be having issues with this most basic of basic concept??
bplus says let's do fireworks today!
Oh and Happy Birthday to Terry!
b = b + ...
01-01-2025, 12:30 AM
@steve: Nice explanation. Kinda verbose though.
But I think you are taking things too literally. You need to lighten up. We weren't at all that serious, just joking around and bullsh*tting I know WHY those things can't be done, it's just interesting to note them. Anyway, you are a great Administrator and I like you. No hard feelings.. I apologize if I was wasting your time.
01-01-2025, 02:13 AM
(12-31-2024, 10:16 AM)SMcNeill Wrote: Guys, why are you making it seem like this is complicated?? This is VERY simple and easy to understand. Let me break it down to you. Code: (Select All)
Pete |
« Next Oldest | Next Newest »
|