1. Arnaud Bailly
  2. PowerBuilder
  3. Thursday, 2 April 2020 08:44 AM UTC

Everything is in the title I guess. 

Accepted Answer
René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 2 April 2020 09:35 AM UTC
  2. PowerBuilder
  3. # Permalink
0
Votes
Undo

AFAIK: No.

You may specify an event name as parameter and trigger this event by name using the TriggerEvent function. But you can't specify parameters.

Or you specify an "callback" object that provide a public function (or event) that you may call from the function.

Comment
Thanks, that's what I thought but I also saw this https://www.rgagnon.com/pbdetails/pb-0133.html
  1. Arnaud Bailly
  2. Thursday, 2 April 2020 09:55 AM UTC
Indirect allows you to set or get the value of an instance variable and have it automatically trigger functions.

Example:



If Not gnv_app.IsLicenseActive Then



Would cause the 'getter' function to run which would be some code to determine if the program license is active.
  1. Roland Smith
  2. Thursday, 2 April 2020 14:42 PM UTC
Sure, I understood that. But this seemed to hint at some "undocumented" aspects of PB so it left me wondering if there would not be a similar trick for passing functions around
  1. Arnaud Bailly
  2. Thursday, 2 April 2020 20:10 PM UTC
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 2 April 2020 19:08 PM UTC
  2. PowerBuilder
  3. # 1
0
Votes
Undo

Hi Arnaud;

  I do this all the time in my frameworks and have for years (OK, decades - LOL)! As you have probably found in the function painter though, using another global function as an argument results in an error(s).

    Sooooooo ....  The trick here is to use an NVUO as a function-to-function broker.

Design:

Function #1 => NVUO => Function #2 => NVUO => Function #3 => NVUO => Function #NN

   Here is a real simple example:  my simple test code of F#1 => NVUO = F#2. Where F1 sets the calling parameter to 2 and F#2 computes its argument from F#1 to return argument * 100.

Test Call:    MessageBox  ("Func-2-func Test"  ,  String ( fn_one ( 2 ) ) )

Fn_one Code:

Int              li_num
nc_broker    lo_broker
lo_broker    =  CREATE nc_broker
li_num        =  lo_broker.of_func2 (ai_num )
Destroy       lo_broker
Return        li_num

NVUO Code:

Int        li_num
li_num   = fn_two ( ai_number )
Return   li_num

Fn_two Code:

Int        li_num
li_num  = ai_num  *  100
Return  li_num

    Using this approach, even F1 could call a succession of functions F2,F3,F4 etc in a row using the NVUO as the function to function broker. In fact, what have here is an MVC design - just like we see in PB2019's new "C# Web API".  Add in recursion, and the NVUO can even broker into itself to call a slew of other GF's in one thread. OK, maybe that's a bit too much for the synapse connections for the moment (working on 5 cups plus of coffee now ... whee).

On yeah .. the test result ...

  Now with a little more "creative" design and programming, you can make the NVUO "broker" handle "dynamic" routing to any other GF(s) on-the-fly vs my hard coded example above.   ;-)

Food for thought.

HTH

Regards ... Chris

  

Comment
Thanks Chris. That makes sense and could be helpful. I wish there was a way to introspect dynamically function and call them but that;'s a first step.
  1. Arnaud Bailly
  2. Thursday, 2 April 2020 20:09 PM UTC
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.