SHARED statement
#8
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.
Reply


Messages In This Thread
SHARED statement - by TerryRitchie - 03-14-2023, 07:16 PM
RE: SHARED statement - by bplus - 03-14-2023, 08:01 PM
RE: SHARED statement - by RhoSigma - 03-14-2023, 10:38 PM
RE: SHARED statement - by Kernelpanic - 03-14-2023, 11:33 PM
RE: SHARED statement - by SMcNeill - 03-15-2023, 01:43 AM
RE: SHARED statement - by TerryRitchie - 03-15-2023, 03:18 AM
RE: SHARED statement - by mnrvovrfc - 03-15-2023, 12:23 PM
RE: SHARED statement - by SMcNeill - 03-15-2023, 02:07 PM
RE: SHARED statement - by TempodiBasic - 03-19-2023, 11:51 PM



Users browsing this thread: 4 Guest(s)