(05-04-2024, 11:39 PM)SMcNeill Wrote: Here's a question: What happens when you do the following?I'm getting quite angry.
X = 1
X = 2
X = 3
?
Is X now 1, 2, 3?
Of course not!! One variable can NOT contain three different values in it. Things just don't work like that. One value overwrites another, and the variable is only the last value.
Now, what happens when you try the following?
DIM X AS LONG
DIM X AS SINGLE
DIM X AS STRING
Is X now a LONG, SINGLE, STRING?
Of course not!! One variable can only be one type at a time. If it wasn't, how the hell would you ever work with it??
x = "a"
x = "a" + 1
Now, what the heck is x?? Is it "a1"? Is it "a" + chr$(1)? If it "b"?
Who knows!! It might be milk and cookies and snuggles and rainbows, in some insane guy's philosophy. I can tell you what it is in BASIC however -- and we're talking any basic here: IT'S AN ERROR!!
Variable types don't work that way. Never have. Never will.
IF you like suffixes, then use suffixes. There is absolutely NOTHING stopping you from going apeshit crazy and using the same variable name for everything in your code -- including labels and such as well, if you're insane enough to do so.
Code: (Select All)Dim a%, a$, a!, a%%, a$1
a% = 1
a$ = "two"
a! = 3.4
a%% = 4
a$1 = "5"
GoSub a
End
a:
Print a%, a$, a!, a%%, a$1
Return
There's just certain rules of syntax that are non-negotiable.
You can't redefine CONSTS.
CONST a = 3
CONST a = 5 'ERROR!! ERROR!!
You can't assign a variable to be more than a single type.
DIM a AS LONG
DIM a AS SINGLE 'ERROR!! ERROR!!!
It just doesn't work. Never has. Never will.
If that's not acceptable, then you'll probably want to find some other programming language to work in that's more user-friendly for you. Maybe try Java.
You (plural) are answering to questions that I have never asked, starting from a message totally OT, when the question for me was already CLOSED.
I repeat again.
Considered that
DIM X AS INTEGER is the same that DIM X%
demostrated from the fact that:
DIM X AS INTEGER
X = 5
PRINT X%
returns "5"
and considered that I can write
DIM X%
DIM X$
I asked WHY I can't write:
DIM X AS INTEGER
DIM X AS STRING
hypothesizing a bug.
PERIOD.
Once having undestood WHY is not a bug and WHY is not possible to do so, for me the question was CLOSED LONG TIME AGO.
I don't have never asked nothing about philosophies, I don't have never said that I am against the fact that I can't write:
DIM X AS LONG
DIM X AS SINGLE
DIM X AS STRING
What the hell does that:
Quote:X = 1I know from the age of 5 that X=3, and that the variable can't have 3 values at the same time.
X = 2
X = 3
?
Is X now 1, 2, 3?