![]() |
UBOUND - 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: UBOUND (/showthread.php?tid=2421) |
UBOUND - bartok - 02-03-2024 As you can see, I'm in the mood for questions. Look at this: Code: (Select All)
the result is "5". Fine. Look at this: Code: (Select All)
This is less "fine". 1. If OPTION_EXPLICIT is activeted, it says "myArray" is not defined.... why? 2. If OPTION_EXPLICIT is deactiveted, the result is "10"... why? RE: UBOUND - bplus - 02-03-2024 (02-03-2024, 08:54 PM)bartok Wrote: As you can see, I'm in the mood for questions. DIM myArray% is only a varaible NOT an array it needs the () for an array Ubound can make sense of. RE: UBOUND - SMcNeill - 02-03-2024 To highlight what bplus is saying: DIM x DIM x(5) Of the above, which is a variable and which is an array? That's basically what you've did in your code. RE: UBOUND - bartok - 02-04-2024 (02-03-2024, 10:28 PM)SMcNeill Wrote: To highlight what bplus is saying:I thought that "x" was an array 1 x 1, as to say made by 1 variable and I thought that x(5) was an array 6 x 1, made by 6 varibles... so to: Code: (Select All)
I expected the answer "1". So, what is the difference beetween: DIM x%(1) and DIM x%? (I generally use OPTION BASE 1. Without it I would expected "0" and DIM x%(1) would be DIM x%(0)) RE: UBOUND - SMcNeill - 02-04-2024 DIM X(1) is an array with one element. DIM X is a variable. SUB foo(x, y() ) Now, in that SUB, what values can you pass to those parameters? For x, you pass a single value, or a variable. Your y(), you pass a whole array. A variable is NOT the same as a single element array. Variables can never be REDIMed to hold more elements. They have no indexes. The contain just a single value. Even a single-element array has an index. X(0). This index tells you, "THIS IS NOT A VARIABLE." Don't fool yourself into thinking it is. RE: UBOUND - bartok - 02-04-2024 (02-04-2024, 12:28 PM)SMcNeill Wrote: DIM X(1) is an array with one element.Ok, It's clear. Thank's! |