1. Miguel Leeuwe
  2. PowerBuilder
  3. Wednesday, 12 May 2021 11:50 AM UTC

Hi,

When overriding an ancestor, you can call the ancestor's script by doing:

super::event pfc_some_event( )

Now what I have to do is call the script of the ancestor of the ancestor.
I've tried:

super::super::event pfc_some_event( )

but of course that didn't work.

The reason for this, is that I want to call the ancestor code of the ancestor (parent of the parent), but not of the parent itself.

I'm trying to avoid having to copy and paste the code of the ancestor's ancestor.

TIA

Accepted Answer
René Ullrich Accepted Answer Pending Moderation
  1. Wednesday, 12 May 2021 12:52 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi Miguel,

You can specify the ancestor class name instead of the SUPER keyword.

e.g. you could call pfc_w_master::event pfc_some_event( ) in w_sheet

https://docs.appeon.com/pb2019/powerscript_reference/ch06s09.html

HTH,

René

 

 

Comment
  1. Miguel Leeuwe
  2. Wednesday, 12 May 2021 13:01 PM UTC
Aha! Thank you, I thought I'd seen something like that in the past, but just couldn't remember or come up with this.

great!
  1. Helpful
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Wednesday, 12 May 2021 13:35 PM UTC
  2. PowerBuilder
  3. # 1

Hey, Miguel, once you called the ancestor script of the ancestor object, did BOTH ancestors get executed?


Setup:
   ANCESTOR1 script ue_event
       DESCENDENT1 script ue_event of ANCESTOR1
           DESCENDENT2 script ue_event of DESCENDANT1


Code in DESCENDENT2 script of ue_event:
      ...
      ...
      ANCESTOR1::EVENT ue_event()


Does this occur?
     ANCESTOR1 ue_event fires
     DESCENDENT1 ue_event files
     DESCENDENT2 ue_event continues at the line after the call to ANCESTOR1?


OR does this occur:
     ANCESTOR1 ue_event fires
     DESCENDENT2 ue_event continues at he line after the cann to ANCESTOR1?


Thanks! I ask because the documentation is not clear on this and I cannot remember having this situation in my own code.

Comment
  1. Miguel Leeuwe
  2. Wednesday, 12 May 2021 14:13 PM UTC
Hi Olan,

I have a datawindow control on a window and in it's pfc_addrow() event I have UNchecked "Extend ancestor class" (so that's an override).



Then I have this call in its code:

long ll_rc

ll_rc = pfc_u_dw::event pfc_addrow()



It first executes the code of pfc_addrow() in the pfc_u_dw object and then comes back to the event on the control of my window. So it's skipping the pfc_addrow() in the u_dw object, which is exactly what I want.



In your words:

ANCESTOR1 ue_event fires

DESCENDENT2 ue_event continues at he line after the call to ANCESTOR1?



regards
  1. Helpful
  1. Olan Knight
  2. Wednesday, 12 May 2021 14:38 PM UTC
Perfect, thank you!
  1. Helpful
There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Wednesday, 12 May 2021 12:49 PM UTC
  2. PowerBuilder
  3. # 2

Couldn't you create a new event on the ancestor that calls the event you need.  Then you can call the new event when you need that super::super event.

Comment
  1. Miguel Leeuwe
  2. Wednesday, 12 May 2021 13:00 PM UTC
Hi Kevin, yes indeed, that would be a solution.

Cheers
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.