Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DIM - AS - VARIABLE TYPE likely bug
#15
Here's a question:  What happens when you do the following?

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.
Reply


Messages In This Thread
DIM - AS - VARIABLE TYPE likely bug - by bartok - 05-03-2024, 06:59 AM
RE: DIM - AS - VARIABLE TYPE likely bug - by SMcNeill - 05-04-2024, 11:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Experimenting with a "StringList" type for simpler handling of string arrays/lists Heimdall 18 1,232 12-19-2025, 12:51 PM
Last Post: Heimdall
  Sub not Reconizing Dim as String pmackay 18 1,476 10-16-2025, 03:32 PM
Last Post: pmackay
  for performance, what's the best variable type to use for boolean _TRUE & _FALSE ? madscijr 12 1,256 09-29-2025, 02:59 PM
Last Post: dakra137
  Loading from file into _MEM? and LEN a TYPE... Unseen Machine 9 976 08-03-2025, 02:55 AM
Last Post: SMcNeill
  Either I'm doing MID$( wrong or it has a bug TDarcos 4 813 04-13-2025, 11:14 PM
Last Post: TDarcos

Forum Jump:


Users browsing this thread: 1 Guest(s)