1. Michael Connell
  2. PowerBuilder
  3. Thursday, 16 September 2021 07:37 AM UTC

Hi,

We have a legacy PB application which defines a user object (n_tr) as the global transaction object.

n_tr inherits from the PFC object pfc_n_tr which has a user defined function of_disconnect() which takes no parameters.

In the legacy code I found the statement of_disconnect(SQLCA). Running the debugger showed that the function being called was the parameter-less function pfc_n_tr.of_disconnect() i.e. the statement of_disconnect(SQLCA) seems to be equivalent to SQLCA.of_disconnect().

I always understood that PB found functions by matching the name and parameter list, so how does of_disconnect(SQLCA) match the parameter-less function of_disconnect() in pfc_n_tr? How does it even find the function?

Is this another way of calling a function that I'm not aware of, or is it a feature of the version of PB we are using (PB 2021), or is it perhaps a bug?

Regards,

Michael Connell.

Miguel Leeuwe Accepted Answer Pending Moderation
  1. Thursday, 16 September 2021 08:19 AM UTC
  2. PowerBuilder
  3. # 1

Hi,

Maybe someone added the of_disconnect(SQLCA) function to the inherited n_tr object in the past. (which absolutely makes no sense to me, since to disconnect a transaction object, you'd call the parameterles function of the corresponding object.).

Where is the of_disconnect(SQLCA) defined? In n_tr ?

 

Comment
There are no comments made yet.
Michael Connell Accepted Answer Pending Moderation
  1. Thursday, 16 September 2021 08:41 AM UTC
  2. PowerBuilder
  3. # 2

Miguel,

That's exactly what I don't understand. There is no function of_disconnect() which takes SQLCA as a parameter. It's not there now and it never was.

And yet the application rebuilds and runs perfectly OK. And as I said previously, if you run the debugger, the statement of_disconnect(SQLCA) passes control to the parameter-less function of_disconnect() in pfc_n_tr.

I must admit I'm at a loss to understand what's going on here.

Regards,

Michael Connell.

Comment
  1. Miguel Leeuwe
  2. Thursday, 16 September 2021 09:07 AM UTC
Hmm, that's weird.

Do a full rebuild and optimize all of your libraries.

Put in a stop where the function with the parameter is being called and do a "step into" in the debugger, see where you enter.

weeeeeird :)
  1. Helpful
  1. Miguel Leeuwe
  2. Thursday, 16 September 2021 09:09 AM UTC
Is the call to of_disconnect(sqlca) preceded with an object name, like sqlca.of_disconnet()? If not, it might just be a global function with a very inconvenient name.
  1. Helpful
There are no comments made yet.
Michael Connell Accepted Answer Pending Moderation
  1. Thursday, 16 September 2021 10:48 AM UTC
  2. PowerBuilder
  3. # 3

Hi again Miguel,

Yes, I agree - very weird.

Did another full rebuild as you suggested and then ran the debugger once again with exactly the same results.

No errors in the build. Application runs as expected. Statement of_disconnect(SQLCA) transfers control to the parameter-less function pfc_n_tr.of_disconnect() .

See the attachments for details.

Regards,

Michael Connell.

Attachments (5)
Comment
  1. Benjamin Gaesslein
  2. Thursday, 16 September 2021 11:40 AM UTC
Incredibly, this also works:

of_execute( SQLCA, 'select 1 from dual')

It's not bound to SQLCA either, it seems like any function can be called this way. Say you have an instance of an object called inv_object that has a function called of_load(). You can call this function using both inv_object.of_load and of_load( inv_object )



I'm guessing this is some leftover undocumented PB feature.
  1. Helpful 3
  1. Miguel Leeuwe
  2. Thursday, 16 September 2021 15:05 PM UTC
Incredible! But I've seen more things that should have been captured by a compiler and they're no, related to parameters.

Anyway, you hit the nail Benjamin!

regards.
  1. Helpful
  1. David Peace (Powersoft)
  2. Thursday, 18 November 2021 14:07 PM UTC
I've been using PB for decades since version 4 and I've not noticed that feature before. I've seen plenty of weird things but not that one :-)



That truly is WSH (Weird Stuff Happens (polite form), we registered this acronym shortly after we started working with PB for just these things! LOL!

  1. Helpful
There are no comments made yet.
Michael Connell Accepted Answer Pending Moderation
  1. Thursday, 16 September 2021 11:53 AM UTC
  2. PowerBuilder
  3. # 4

Benjamin,

Thanks for confirming that I'm not crazy laughing

I think you might be right. It sure looks like some leftover, documented feature.

I guess we file it under "interesting".

Regards,

Michael Connell.

Comment
  1. Andreas Mykonios
  2. Thursday, 16 September 2021 13:31 PM UTC
I wonder if this type of syntax was used in the early versions (1 - 3). I know that the syntax was altered until pb v.5. Maybe Chris that used early versions can clarify. Anyway an interesting observation.



Andreas.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 16 September 2021 14:32 PM UTC
  2. PowerBuilder
  3. # 5

Hi Michael;

  Is sounds like either you are not using a current version of the PFC that matches the PB version you are using OR your PFC framework has an "overloaded" version of the "of_disconnect" method (hopefully) in the "Extension" layer. If the latter, just remove the overloaded method version.

FYI: https://github.com/OpenSourcePFCLibraries

Regards ... Chris

Comment
There are no comments made yet.
Bruce Armstrong Accepted Answer Pending Moderation
  1. Thursday, 16 September 2021 20:40 PM UTC
  2. PowerBuilder
  3. # 6

I've been able to reproduce this using just a few objects.

My guess is that it's obsolete syntax that is still supported where of_disconnect ( SQLCA ) is the equivalent of SQLCA.of_disconnect()

Not just SQLCA, but any object.  I create a custom non-visual called n_test with a function called of_testing (no arguments).  I then coded in a script:

n_test  lnv_test
lnv_test = Create n_test
of_testing ( lnv_test )

And it works.  I wouldn't recommend continuing to use it though.

Comment
  1. Benjamin Gaesslein
  2. Friday, 17 September 2021 06:17 AM UTC
Works with arguments, too, btw. Instead of lnv_test.of_testing( arg1, arg2 ) you can call of_testing( lnv_test, arg1, arg2 ).
  1. Helpful 2
  1. Miguel Leeuwe
  2. Friday, 17 September 2021 07:41 AM UTC
Well, I guess this should solve the mystery then. Not very consistent though: I can't do a "lw_window.Close()". It has to be "Close(lw_window)".

regards. Great info!
  1. Helpful
  1. Arnd Schmidt
  2. Friday, 17 September 2021 09:07 AM UTC
Better

::Close(lw_window)



There are a lot of pitfalls in the PowerScript grammar and the event / function flow that you paid for with your time and money in the last 2 decades.

The license costs are cheap, but the bugs in the tool eat up what you saved.



SAP/Appeon missed to modernize the language and runtime.

  1. Helpful
There are no comments made yet.
Michael Connell Accepted Answer Pending Moderation
  1. Monday, 20 September 2021 06:35 AM UTC
  2. PowerBuilder
  3. # 7

Guys,

Thanks for all your input.

I guess I'll just chalk this up to experience and re-code the statement as SQLCA.of_disconnect().

Regards,

Michael Connell.

Comment
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.