In Visual Foxpro there was a function called TYPE that you could use to test if a variable was initialized and what type it was. Is there a way to do this in XOJO without generating an exception?
For example:
? TYPE(“cVariable”)
Would return “U” if undefined
“C” if a character variable
“N” if a numeric variable
Use a Variant or Auto. You still have to know the variable name but you can test to see if it is null (not initialized). Use If MyVariant.IsNull or If MyAuto = nil.
Use a Dictionary and store your “variables” as keys. You can test if the “variable” is defined with MyDict.HasKey and if it’s been initialized as above.
I recommend neither of these. Take advantage of the strongly typed language.