How to Iterate Funtional Class Variables

Discussion forum about all things Gupta, OpenText and the community.
ozmenbetul
Turkey
Posts: 292
Joined: 28 Aug 2019, 08:57
Location: Turkey

How to Iterate Funtional Class Variables

Post by ozmenbetul » 20 Sep 2011, 07:46

Hello,

I am building normal desktop application and i am using funcitonal class at my application.

I am trying to craete string from my class variable such as serialize, deserialize mechanism, by this way i need to iterate my all class variable

i am able to access variable value with SalCompileAndEvulate function. but i am not able to access variable name.

How could i access my class variable names like java reflection methods.

or is there any way to make class serialize, unserialize

Code: Select all

!!CB!! 244
Functional Class: Test
   Description:
   Derived From
   Class Variables
   Instance Variables
      Number: nNumber1
      Number: nNumber2
      String: strString1
   Functions
I need to get nNumber1,nNumber2,strString1 name

clemdoc
Austria
Posts: 225
Joined: 08 Mar 2017, 09:51
Location: Austria

Re: How to Iterate Funtional Class Variables

Post by clemdoc » 20 Sep 2011, 09:37

Hi!
Betul Ozmen wrote:Hello,

I am building normal desktop application and i am using funcitonal class at my application.

I am trying to craete string from my class variable such as serialize, deserialize mechanism, by this way i need to iterate my all class variable

i am able to access variable value with SalCompileAndEvulate function. but i am not able to access variable name.

How could i access my class variable names like java reflection methods.
AFAIK, you can do this only by using the CDK.
Betul Ozmen wrote:or is there any way to make class serialize, unserialize
Depending on what you really want to do, you could try to use the XML stuff (SalXMLSerializeUDV etc.) to serialize your class. However I fear that you can only write to files using these functions, you can't use them to give you strings, alas.

Greetings, clem

ozmenbetul
Turkey
Posts: 292
Joined: 28 Aug 2019, 08:57
Location: Turkey

Re: How to Iterate Funtional Class Variables

Post by ozmenbetul » 20 Sep 2011, 15:31

Hello again,

thanks for your answer, but i know these answer.

i am searching for variable reflection metod such as java does. I thing there is no way to do it.

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 3392
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: How to Iterate Funtional Class Variables

Post by Dave Rabelink » 20 Sep 2011, 16:24

Well, there is no automatic solution. The SDK method only works when running in IDE. The variable names are lost when running as executable.

In theory, there is a way but then Unify must "enable" the variable name resolving to the outside.

Another solution is to create your own:

Create a CDK app which creates a function in your class which automatically returns a separated list of variable names.

Then use the SalCompileAndEvaluate function to call the function and parse the returned list and evaluate every variable with another SalCompileAndEvaluate.

It is not the easy use you really want, but this is imho the only way without reverting to the SalXMLSerialize functions.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

User avatar
markus.essmayr
Austria
Posts: 892
Joined: 06 Mar 2017, 06:07
Location: Austria

Re: How to Iterate Funtional Class Variables

Post by markus.essmayr » 21 Sep 2011, 06:37

Hi Dave,

first of all, I'm not used to CDK development, so this is just a guess!

You wrote, that variable names are not available when running a TD-application as EXE.
But SalCompileAndEvaluate is able to access variable names in an EXE, so maybe there is a way!?!?

What do you think?

Greetings,
Max
Markus Eßmayr
teamdeveloper@t-mx.com

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 3392
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: How to Iterate Funtional Class Variables

Post by Dave Rabelink » 21 Sep 2011, 11:00

Hi Max,

Yes you are right. SalCompileAndEvaluate can use a variable name (as string) and evaluate it. So there must be an internal variable table with context info available at runtime. Also the SalXML functionality fetches the variable names.

But this is internal knowledge which 'seems' to be unavailable to the outside (eg methods within CDK).
Quite some time ago I investigated if there is an undocumented method anywhere within the set of TD dll's which could be a way into the internal variable table.
I found some functions which could be related to this, but were not able to utilize it.

I don't know why Gupta decided to shield it from developers. Maybe it could be a security issue. But then again, when using SalXMLSerialize functions you can discover the variable names from classes without problems.

I would like to see that CDK functions would return the variable names when running from exe and maybe it is a simple change to enable it.
Can Unify internals comment on this?
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 1 guest