dim as integer X1 = 2
const as integer X2 = 2
dim as const integer X3 = 3
type abType
dim as short a, b
end type
dim as abType AB1 = type(1, 1)
const as abType AB2 = type(1, 1) '<-- Not allowed
dim as const abType AB3 = type(1, 1)
union baUnion
dim as long ba
type
dim as short b,a
end type
end union
dim as baUnion BAU1
const as abUnion ABU2 '<-- Not allowed
dim as const baUnion BAU3 = 1 '<-- Not ok, how to set?
union abUnion
type
dim as short a, b
end type
dim as long ab
end union
dim as abUnion ABU1
dim as const abUnion ABU3 = type(1, 1) '<-- OK
print ABU3.ab
dim as integer X1 = 2
const as integer X2 = 2
dim as const integer X3 = 3
type abType
dim as short a, b
end type
dim as abType AB1 = type(1, 1)
const as abType AB2 = type(1, 1) '<-- Not allowed
dim as const abType AB3 = type(1, 1)
union baUnion
dim as long ba
type
dim as short b,a
end type
end union
dim as baUnion BAU1
const as baUnion ABU2 = type(1) '<-- Not allowed
dim as const baUnion BAU3 = type(1) '<-- OK
union abUnion
type
dim as short a, b
end type
dim as long ab
end union
dim as abUnion ABU1
dim as const abUnion ABU3 = type(1) '<-- OK
dim as const abUnion ABU4 = type(1, 1) '<-- OK
print ABU3.ab
Thanks, my conclusion:
A) const as ... is not possible, use dim as const ...
B) The order of variables within the union is important for assigning a value
union abUnion
type
dim as short a, b
end type
dim as long ab
end union
dim as const abUnion ABU1 = type(&hffffffffl) '<-- OK
print ABU1.a, ABU1.b
dim as const abUnion ABU2 = type(&hffffffffl, &hffffffffl) '<-- OK ?
print ABU2.a, ABU2.b
dim as const abUnion ABU3 = type(&hffffffffl, &hfffffffl) '<-- NOK ?
print ABU3.a, ABU3.b
fxm wrote:Short => 16-bit signed (or 4 hexadecimal digits).
I know, but why is &hffffffffl (8 x f) ok and &hfffffffl (7 x f) wrong?
I also noticed that 'const as ...' is global and 'dim as const ...' is not, so it becomes 'dim shared as const vartype var = type(value)' (lots of text).
CONST as described in CONST wiki page, even though it has a data type, is handled like a literal. Only the compiler knows about it's type. No memory is allocated for it and, can't take the address of it.