QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: Pete on January 31, 2021, 03:17:41 pm
-
https://www.qb64.org/forum/index.php?topic=3558.msg129096#msg129096
Look at line #350 and #351.
i% = UBOUND(ifield$)
REDIM entry$(UBOUND(ifield$))
Rem out i% = UBOUND(ifield$)
In v1.3, the IDE gives a Name already in use error. WTH?
It will accept REDIM entry$(i%)
I know I'm using the upper bounds of an array to DIM another array, but why will it work as coded, where the i% has NO FUNCTION in what's going on in the code, but when we Rem out i% = UBOUND(ifield$), it errors out?
If this doesn't do what I'm talking about, and you are using a more current version, then I just stumbled on an old bug, and the situation has been resolved. If it does error out in the newest version, it's either a bug, or something is going on that just makes no sense to me, since that i% part shouldn't effect the code, period.
Pete
-
Please try it in the latest development build to see if it still happens, so we can try to understand the issue at hand with more detail.
-
Did you try it in the latest build? I would, but I haven't downloaded the latest build yet and I'm not planning on adding it to my overly long to do list. If it doesn't fail in your Windows version, then it's something that has already been worked out. BTW - you don't even have to run the code. Just copy and paste it in the IDE then RE out line #350, and let us know if you get an IDE error message of "Name already in use." on line 351.
Pete
-
I didn't try it.
-
[ This attachment cannot be displayed inline in 'Print Page' view ]
-
Thanks Bill. That's the same thing I get in V1.3. So is this a bug, or what's going on here?
Pete
-
If line 348 is the first ever appearance of the entry$() array in your code, then you allowed QB64 to create it on-the-fly for you, which ended up creating a static array with 10 indexes.
Add REDIM entry$(0) to the beginning of your program to fix the issue. (Not a QB64 bug).
-
Or add this to the beginning of your code:
Both methods will fix the issue.
-
'$DYNAMIC is not an issue, and it didn't fix it. The array entry$() array was already DIM SHARED in line at line #63, so that's not it, but...
I went over the code, and discovered the array ifield$() is LOCAL. Making that DIM SHARED in the main corrects the error.
In short, it looks like this...
EDIT: Okay, back up the truck... So my guess is that i% = UBOUND(ifield$), the UBOUND keyword is establishing a single instance of ifield$(), which I put as a local array, and forgot to pass it or just make it shared in the main. Without that UBOUND statement, no ifield$() array is found in the main, as coded. That has to be it. That must be what Fell meant by QB64 creates a 10 element array on the fly, but with UBOUND???? I don't use UBOUND much, but if this is what happened, I'll know where to look the next time I encounter it. Now I'm curious if QB worked the same way?
Thanks guys,
Pete