09-21-2024, 04:05 AM
(09-21-2024, 02:35 AM)SMcNeill Wrote:It's single because that's the default type for an unsuffixed variable not explicitly DIMmed as something else.(09-21-2024, 02:23 AM)madscijr Wrote: Thank you! That is exactly it.
So the suffix isn't needed for functions and constants but it is for variables.
A suffix isn't needed for variables either, but an unsuffixed variable is always going to refer to just one single variable type.
x = 123 <-- now, is x here a single? an integer? a float? an offset?
Honestly, with just the information you see above, you'd have to call it a single as it defaults to single. The above is the EXACT same thing as typing:
x! = 123
Now, if we instead had code like this:
DEFLNG A-Z
x = 123
The above would make x a LONG because we changed what the variable types were.
And if we have code like this:
DIM x AS _FLOAT
x = 123
The above would make x a FLOAT as that's what we explicitly defined it as.
And, if we have code like this:
DIM x&
x = 123
The above will still x being a SINGLE as x& is not the same as x. x is undefined as it has no suffix, so if defaults back to the standard type -- SINGLE in this case.
When you DIM variable AS TYPE, you set the unsuffixed value to that type. You do nothing to change the suffixed variables and their types.
The following code here is perfectly legal:
Code: (Select All)Dim x%%, x&, x##
x = 123
Print x%%, x&, x##
Print x
Now, what variable type is x in the above?
The default can be changed with the DEF{type} command, e.g., DEFLNG for long.
Is that right?