|
-
Jun 20th, 2024, 02:25 AM
#11
New Member
Re: TwinBasic
 Originally Posted by wqweto
This looks promising. Could be an edge case with refs inside UDTs.
Can you trim it further? Just the UDT declaration and 1-3 lines which don’t work as expected in TB i.e. which require using explicit Item property getter.
Code:
Class Form1
Private Type TIniIO
udtData As Scripting.Dictionary ' Object
udtSection As Scripting.Dictionary ' Object
End Type
Private this As TIniIO
Sub New()
Set this.udtData = CreateObject("Scripting.Dictionary")
this.udtData.Add "Level00", CreateObject("Scripting.Dictionary")
Set this.udtSection = this.udtData("Level00") ' <== this fails at runtime (Default property)
Set this.udtSection = this.udtData.Item("Level00") ' this succeeds
this.udtSection.Add "Level01", "ABC"
Debug.Print "Case 00:" & this.udtData("Level00")("Level01") ' this fails at runtime
Debug.Print "Case 01:" & this.udtData("Level00").Item("Level01") ' this fails at runtime
Debug.Print "Case 02:" & this.udtData.Item("Level00")("Level01") ' this succeeds
Debug.Print "Case 03:" & this.udtData.Item("Level00").Item("Level01") ' this succeeds
End Sub
End Class
Executing '[Form1].Show()'...
Case 02:ABC
Case 03:ABC
[DEBUGGER] Waiting for remaining forms to close...
(time taken: 7.0498795s)
I trimmed this down to identify only those situations that failed. I ran the code from the IDE and used Ignore-Resume Next option. Surprisingly, it is the outer level that does not recognise the Default Method (Case 00 & Case 01).
I tested with many other variations - Global declaration: iniData As Scripting.Dictionary and iniData As Object and a local declaration lclData As Object. I all of these, my test cases succeeded.
I did the extra tests because GCuser99 on Discord uncovered a similar failure that he reported on GitHub #1724 and I hoped to include his evidence here. But, using Strings as the final object did not fail using code similar to his. So I think his circumstance will need its own investigation.
But, both he and I experienced this (or similar) issue when iniData (Dictionary) is declared as a Collection.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|