03-15-2023, 02:07 PM
People need to learn to accept that *ALL* variables in QB64 are defined. By default, every variable is defined with a very basic: (DIM variable AS _DEFAULT_TYPE)
x = 3 .... now, what TYPE of variable is X? Since there's no user-explicit definition, there's the implied (DIM x AS _DEFAULT_TYPE). Without any DEF statement or _DEFINE statement in effect, then x is SINGLE.
Now, let's say we do something such as: DIM x, y AS INTEGER, z, alpha AS _FLOAT, beta AS DOUBLE
What variable types are each of those variables?
x is... we didn't specify, so it's _DEFAULT_TYPE.
y, we declared to be an INTEGER, so it's an INTEGER.
z is... once more, undeclared so it's _DEFAULT_TYPE
alpha is declared to be a _FLOAT
beta is declared to be a DOUBLE
The ONLY shortcut one might use to declare x and y both as INTEGERS at the same time would be:
DIM AS INTEGER x, y
DIM AS _FLOAT z, alpha
DIM AS DOUBLE beta
^A completely different syntax, with only one variable type being allowed per line, and that type has to be declared before any of the variable names. Makes for a great shorthand, but it's definitely not the same as placing the variable name before the type declaration.
And that's basically the whole issue for why Example 4 wasn't working the way the user was thinking it should. Two very similar ways to declare variables, but with vastly different results for each of the specific syntax uses.
x = 3 .... now, what TYPE of variable is X? Since there's no user-explicit definition, there's the implied (DIM x AS _DEFAULT_TYPE). Without any DEF statement or _DEFINE statement in effect, then x is SINGLE.
Now, let's say we do something such as: DIM x, y AS INTEGER, z, alpha AS _FLOAT, beta AS DOUBLE
What variable types are each of those variables?
x is... we didn't specify, so it's _DEFAULT_TYPE.
y, we declared to be an INTEGER, so it's an INTEGER.
z is... once more, undeclared so it's _DEFAULT_TYPE
alpha is declared to be a _FLOAT
beta is declared to be a DOUBLE
The ONLY shortcut one might use to declare x and y both as INTEGERS at the same time would be:
DIM AS INTEGER x, y
DIM AS _FLOAT z, alpha
DIM AS DOUBLE beta
^A completely different syntax, with only one variable type being allowed per line, and that type has to be declared before any of the variable names. Makes for a great shorthand, but it's definitely not the same as placing the variable name before the type declaration.
And that's basically the whole issue for why Example 4 wasn't working the way the user was thinking it should. Two very similar ways to declare variables, but with vastly different results for each of the specific syntax uses.