|
Post by Roger Cabo on Jul 31, 2022 15:49:38 GMT 1
Hi,
I got another issue with Type and a Boolean array inside. This small example should stop. But it does not.
Type myData Boo(1) As Boolean EndType
Dim db(10) As myData
db(0).Boo(0) = True db(0).Boo(1) = False
If db(0).Boo(0) = True Stop EndIf
any idea? Thank you!
|
|
|
Post by dragonjim on Jul 31, 2022 16:42:45 GMT 1
Hi, It works for me if you change Boo(1) as Boolean to Boo(0 To 1) as Boolean... Otherwise I get a variable error.
|
|
|
Post by Roger Cabo on Jul 31, 2022 17:07:56 GMT 1
Hi, It works for me if you change Boo(1) as Boolean to Boo(0 To 1) as Boolean... Otherwise I get a variable error. Thanks!
Anyway strange.. doesn't work for me. Seems after passing db(0).Boo(0) = True db(0).Boo(0) stays False
Type myData Boo(0 To 1) As Boolean EndType
Dim db(0) As myData
db(0).Boo(0) = True MsgBox db(0).Boo(0)
---------------------------------------------
I use now
Type myData Boo(1) As Byte EndType
Dim db(0) As myData
Seems working with Boo(0) = True
|
|
|
Post by dragonjim on Jul 31, 2022 17:25:42 GMT 1
Interesting. I have the same problem. There has always been problems with Booleans in Types. A quick workaround is to change type from Boolean to Byte as you have.
|
|
|
Post by (X) on Jul 31, 2022 18:15:00 GMT 1
This shows you CAN define boolean UDT members individually and they seem to behave as expected.
As you say, the UDT array: B_as_Byte() works OK, and, the UDT array: C_as_Bool() of type Bool does not. Yet, an array defined in the main body: D(0) as Bool works fine.
It seems there is a problem with GFA's User Defined Type framework when trying to use an array of Boolean members.
$Library "gfawinx" $Library "UpdateRT" UpdateRuntime ' Patches GfaWin23.Ocx
Type myData B0 As Bool B1 As Bool B2 As Bool B3 As Bool B4 As Bool B5 As Bool B6 As Bool B7 As Bool B8 As Bool B_as_Byte(0 To 0) As Byte C_as_Bool(0 To 0) As Bool EndType
Dim db(0) As myData Trace Dim?(db()) Trace Len(myData) Debug Debug "Set first 9 bits to true" db(0).B0 = True db(0).B1 = True db(0).B2 = True db(0).B3 = True db(0).B4 = True db(0).B5 = True db(0).B6 = True db(0).B7 = True db(0).B8 = True
Debug "Show first byte of memory..." Debug Bin(Peek(V:db(0)), 8) Debug Bin(Peek(V:db(0) + 1), 8)
Trace CBool(db(0).B0) Trace CBool(db(0).B1) Trace CBool(db(0).B2) Trace CBool(db(0).B3) Trace CBool(db(0).B4) Trace CBool(db(0).B5) Trace CBool(db(0).B6) Trace CBool(db(0).B7) Trace CBool(db(0).B8)
Debug Debug "Set first 9 bits to false"
db(0).B0 = False db(0).B1 = False db(0).B2 = False db(0).B3 = False db(0).B4 = False db(0).B5 = False db(0).B6 = False db(0).B7 = False db(0).B8 = False
Debug "Show first byte of memory..." Debug Bin(Peek(V:db(0)), 8) Debug Bin(Peek(V:db(0) + 1), 8)
Trace CBool(db(0).B0) Trace CBool(db(0).B1) Trace CBool(db(0).B2) Trace CBool(db(0).B3) Trace CBool(db(0).B4) Trace CBool(db(0).B5) Trace CBool(db(0).B6) Trace CBool(db(0).B7) Trace CBool(db(0).B8)
Debug Debug Bin(Peek(V:db(0)), 8)
Debug Debug "B_as_Byte() array" db(0).B_as_Byte(0) = True db(0).B_as_Byte(1) = False Trace CBool(db(0).B_as_Byte(0)) Trace CBool(db(0).B_as_Byte(1))
Debug Bin(Peek(V:db(0).B_as_Byte(0)), 8) Debug Bin(Peek(V:db(0).B_as_Byte(1)), 8)
Debug Debug "C_as_Bool() array" Dim T As Bool = True Dim F As Bool = False Trace T Trace F db(0).C_as_Bool(0) = T ' True db(0).C_as_Bool(1) = F ' False Trace CBool(db(0).C_as_Bool(0)) Trace CBool(db(0).C_as_Bool(1)) Debug Bin(Peek(V:db(0).C_as_Bool(0)), 8) Debug Bin(Peek(V:db(0).C_as_Bool(1)), 8)
Dim D(0) As Bool D(0) = True Trace D(0) D(0) = False Trace D(0)
|
|