I'm migrating what used to be a lot of GLOBAL data into a CLASS structure. The simple variables have migrated just fine; I'm now hitting the 1st of the odder types.
I'm stumped here on what is probably just a syntax problem, but I've read the Help over and over and gotten nowhere.
Below is a simple bit of test code which demonstrates the problem. My questions are:
1) I seem to be forced to DIM the UDT array in BOTH the Constructor and in the Method/Property. Great if its a fixed size, but what if it's a dynamically growing type that's REDIMed occasionally? I don't want fixed dimensions in the Method for sure.
2) Can the Method/Property return individual fields from a specific indexed entry in the UDT array? Or am I forced to return the whole UDT item? Just what is the syntax for this? I'm stumped.
As you can tell, I'm really lost here.
Here's the small test code. It sits as of my last trial, but I've gone through dozens of attempts, Properties, Methods, Returning individual UDT fields, returning the UDT.
I'm stumped here on what is probably just a syntax problem, but I've read the Help over and over and gotten nowhere.
Below is a simple bit of test code which demonstrates the problem. My questions are:
1) I seem to be forced to DIM the UDT array in BOTH the Constructor and in the Method/Property. Great if its a fixed size, but what if it's a dynamically growing type that's REDIMed occasionally? I don't want fixed dimensions in the Method for sure.
2) Can the Method/Property return individual fields from a specific indexed entry in the UDT array? Or am I forced to return the whole UDT item? Just what is the syntax for this? I'm stumped.
As you can tell, I'm really lost here.
Here's the small test code. It sits as of my last trial, but I've gone through dozens of attempts, Properties, Methods, Returning individual UDT fields, returning the UDT.
Code:
TYPE TestType i AS LONG s AS STRING * 10 END TYPE CLASS cTestClass INSTANCE Tests() AS TestType CLASS METHOD CREATE() ' Constructor DIM Tests(10) AS TestType Tests(1).i = 333 Tests(1).s = "String" END METHOD INTERFACE iTestClass: INHERIT IUNKNOWN ' Define the interface PROPERTY GET Tests(BYVAL ix AS LONG) AS TestType DIM Tests(10) AS TestType PROPERTY = Tests(ix) END PROPERTY END INTERFACE END CLASS FUNCTION PBMAIN () AS LONG LOCAL x AS iTestClass LOCAL Answer AS TestType LOCAL j AS LONG LET x = CLASS "cTestClass" Answer = x.Tests(1) MSGBOX "Data=" & FORMAT$(Answer.i) END FUNCTION
Comment