-
-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect array indexing when passed as parameter #824
Comments
Thanks for reporting. Using Will keep you updated with the fix of this. :-) |
Thank you very much for replying.
What's the most annoying here, is that
Alas, it doesn't prevent the problem: #pragma array_base=1
sub PrintArray(arr() as integer)
dim i as integer
for i = lbound(arr, 1) to ubound(arr, 1)
print i; ": "; arr(i)
next i
end sub
dim arr(3) as integer => {10, 20, 30}
PrintArray arr Gives the same incorrect output:
I hope this will be fixed soon. To me, 1-based arrays seem very beneficial in Basic, because I find it very awkward to always calculate |
Yes, but that's because, regardless of the array base functions are totally agnostic of the arrays and dimensions they receive, and operate on base 0. Giving support to these will be very expensive (in terms on memory and speed), but can be done using using the internal LBound and UBound tables. I will try to implement a solution. In the (long) meantime, you can use #pragma array_base=1
sub PrintArray(arr() as integer)
dim i as integer
for i = 0 to ubound(arr, 1) - lbound(arr, 1)
print i; ": "; arr(i)
next i
end sub
dim arr(3) as integer => {10, 20, 30}
PrintArray arr This will work regardless of how the array was declared and the array base. EDIT: Array declarations will be changed in the future 2.x, and all of them will be 0-based or 1-based only. I'm seriously considering removing the DIM a(x1 TO y1, x2 TO y2...) syntax. |
Please, consider joining the official telegram channel to discuss this with the community: |
Works correctly now, thank you! 👍 |
Hi,
Having the following code:
The expected output is:
Actual output:
Is it a bug or a feature?
The text was updated successfully, but these errors were encountered: