Is there any keyword to access derivered class variable

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

Is there any keyword to access derivered class variable

Post by ozmenbetul » 15 Nov 2011, 21:53

Hello,

I have two class;

one class is loging class as below;

Code: Select all

!!CB!! 244
Functional Class: logClass
   Description:
   Derived From
   Class Variables
   Instance Variables
   Functions
      Function: doLog
         Description:
         Returns
         Parameters
         Static Variables
         Local variables
            String: sLogText
         Actions
            Set sLogText = sLogText || this.sName
            Set sLogText = sLogText || this.sSurname
And second class is derivered from this logClass as below;

Code: Select all

!!CB!! 244
Functional Class: stdClass
   Description:
   Derived From
      Class: logClass
   Class Variables
   Instance Variables
      String: sName
      String: sSurname
   Functions
      Function: save
         Description:
         Returns
         Parameters
         Static Variables
         Local variables
         Actions
            Call logClass.doLog(  )
i want to access class variable from my first class because i dont want to create log functon for my all new class.

but i am not able to access class variable from fist child class.

Is there any way to do that.

Thank you for every one who interested in.

logClass <- stdClass
access_metod -> variable

didier

Re: Is there any keyword to access derivered class variable

Post by didier » 15 Nov 2011, 23:20

it"s easy : use virtuals functions


Set sLogText = sLogText || ..getName()
Set sLogText = sLogText || ..getSurname()

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

Re: Is there any keyword to access derivered class variable

Post by ozmenbetul » 16 Nov 2011, 07:33

Hello

@didier as you said i crate getter and setter function. but its gave me same error. i tried both this.getName() and ..getName() i think there is no operator for double dot ".."

for explain my question right i added sample file

Thank You
You do not have the required permissions to view the files attached to this post.

didier

Re: Is there any keyword to access derivered class variable

Post by didier » 16 Nov 2011, 09:42

Save your code as text

You need to declare getter and setter in both class ( empty function in base classe)

didier

Re: Is there any keyword to access derivered class variable

Post by didier » 16 Nov 2011, 09:53

The solution

!!CB!! 244
Functional Class: logClass
Description:
Derived From
Class Variables
Instance Variables
Functions
Function: doLog
Description:
Returns
Parameters
Static Variables
Local variables
String: sLogText
Actions
Set sLogText = sLogText || ..getName( )
Set sLogText = sLogText || ..getSurname( )
! Virtual declaration for signature
Function: getName
Description:
Returns
String:
Parameters
Static Variables
Local variables
Actions
Function: setName
Description:
Returns
Parameters
String: sName
Static Variables
Local variables
Actions
Function: getSurname
Description:
Returns
String:
Parameters
Static Variables
Local variables
Actions
Function: setSurname
Description:
Returns
Parameters
String: sSurname
Static Variables
Local variables
Actions
Functional Class: stdClass
Description:
Derived From
Class: logClass
Class Variables
Instance Variables
String: sName
String: sSurname
Functions
Function: save
Description:
Returns
Parameters
Static Variables
Local variables
Actions
Call logClass.doLog( )
Function: getName
Description:
Returns
String:
Parameters
Static Variables
Local variables
Actions
Return this.sName
Function: getSurname
Description:
Returns
String:
Parameters
Static Variables
Local variables
Actions
Return this.sSurname
Function: setName
Description:
Returns
Parameters
String: sName
Static Variables
Local variables
Actions
Set this.sName = sName
Function: setSurname
Description:
Returns
Parameters
String: sSurname
Static Variables
Local variables
Actions
Set this.sSurname = sSurname
You do not have the required permissions to view the files attached to this post.

Christof
Germany
Posts: 191
Joined: 06 Mar 2017, 07:27
Location: Frankfurt, Germany

Re: Is there any keyword to access derivered class variable

Post by Christof » 16 Nov 2011, 10:14

You need not declare these functions (getName(), getSurname()) in the base class as well. They serve as a template for virtual function calls and need to have the same signature and return types as the concrete implementations in the derived classes.

Greetings,
Christof

RainerE
Germany
Posts: 2225
Joined: 27 Apr 2021, 12:40
Location: Germany

Re: Is there any keyword to access derivered class variable

Post by RainerE » 16 Nov 2011, 14:00

Hi!

1st: Please do not save source code in format 'Normal' or 'Compiled'. Please always use the format 'Text'. Otherwise you cannot open the sourcecode in diffent TD versions (like me).

2nd: didier means:

Code: Select all

!!CB!! 244
Functional Class: logClass
   Description:
   Derived From
   Class Variables
   Instance Variables
   Functions
      Function: doLog
         Description:
         Returns
         Parameters
         Static Variables
         Local variables
            String: sLogText
         Actions
            Set sLogText = sLogText || ..getName()
            Set sLogText = sLogText || ..getSurname()
      !
      ! Prototypes for late bound functions
      Function: getName
         Description:
         Returns
            String:
         Parameters
         Static Variables
         Local variables
         Actions
      Function: getSurname
         Description:
         Returns
            String:
         Parameters
         Static Variables
         Local variables
         Actions
Functional Class: stdClass
   Description:
   Derived From
      Class: logClass
   Class Variables
   Instance Variables
      String: sName
      String: sSurname
   Functions
      Function: save
         Description:
         Returns
         Parameters
         Static Variables
         Local variables
         Actions
            Call doLog()
      !
      ! Implementation of late bound functions
      Function: getName
         Description:
         Returns
            String:
         Parameters
         Static Variables
         Local variables
         Actions
            Return sName
      Function: getSurname
         Description:
         Returns
            String:
         Parameters
         Static Variables
         Local variables
         Actions
            Return sSurname
Regards,
Rainer

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

Re: Is there any keyword to access derivered class variable

Post by ozmenbetul » 17 Nov 2011, 07:43

Hello,

thanks for every one who interested in.

i tried as you said. its works. but its not solve my problem actually.

i am trying to create adaptive log class for using this log class with all my other class.

i can add function to log class but return type can be different from other class. maybe one class use same variable name and variable type can be string. maybe one other class can use same variable name and variable type can be number.

Thank you

RainerE
Germany
Posts: 2225
Joined: 27 Apr 2021, 12:40
Location: Germany

Re: Is there any keyword to access derivered class variable

Post by RainerE » 17 Nov 2011, 17:15

What about this (attachement)?

Regards,
Rainer
You do not have the required permissions to view the files attached to this post.

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 3 guests