Welcome! Log In Create A New Profile

Advanced

Determine if a Member/Property exists in a class

Posted by Malc 
OK, I've got this class:


...CTest.is class
......PUBLIC
.........iProperty1 is int = 1
.........sProperty2 is string = "Two"
.........vProperty3 is Variant = "Three"
...END

...FUNCTION MemberExists(LOCAL psMemberName is string)
......LOCAL
.........lbExists is boolean = True
.........lvTest is Variant = Null
......WHEN EXCEPTION IN
.........lvTest = {":" + psMemberName}
......DO
.........lbExists = False
......END
...RESULT = lbExists


Now, when I do the following, everything is OK


...LOCAL
......loTest is CTest

...IF loTest:MemberExists("iProperty1") THEN
......Info("This Worked")
...END
...IF NOT loTest:MemberExists("zProperty99") THEN
......Info("This Worked")
...END


But, any attempt to use indirection outside the class fails, e.g.

...LOCAL
......loTest is CTest
......lsTest is string
......lvValue is Variant

...lsTest = "loTest:iProperty1"
...WHEN EXCEPTION IN
......lvValue = {lsTest}
...IN
......Info("Always fails")
...END


Any ideas anyone??


TIA

Malc





Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: