Question on ln in a for/next loop - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: Question on ln in a for/next loop (/showthread.php?tid=3026) Pages:
1
2
|
RE: Question on ln in a for/next loop - Pete - 09-13-2024 Quote:name that tune: Tie A Yellow Ribbon Around The Old Oak Tree Tony Orlando and Dawn. I knew them personally. They used to frequent my father's store. Now a math question: Q: What does Fake News + Phony Politicians = A: Real Problems Pete RE: Question on ln in a for/next loop - Kernelpanic - 09-13-2024 The global "ln" was probably passed to a Procedure(Sub). - A local "ln" is only known in this subprogram and has no effect on the program outside. Why it is -2? Does the local variable also come before a "shared variable" in the main program? Test it! Code: (Select All)
RE: Question on ln in a for/next loop - bplus - 09-13-2024 Why -2? because when you Dim ln as Integer inside the subroutine you set it to zero. Comment that line out and all is as expected. RE: Question on ln in a for/next loop - Kernelpanic - 09-13-2024 @bplus - correct in principle. It is -2 because every new uninitialized variable in Basic is automatically initialized with zero. Zero minus 2 is . . . -2. |