1. David Vasconcelos
  2. PowerBuilder
  3. Friday, 7 December 2018 17:35 PM UTC

I would like to store "rules' in a database column so that I can retrieve the rule and run it. The rule can contain a combination of static text and function calls I would like to run.

Example:

following info would be in a database column.

"Get some info: + of_getdata() +  here is the info"

I would then retrieve it into a string variable and would like to run it as if was being built as a string like below.

ls_string = "Get some info: " + of_getdata() + " here is the results"

 

Is there some function or option Similar to Evaluate in a datawindow or Exec Immediate for SQL.

Any Ideas?

 

Dave V.

 

 

Accepted Answer
mike S Accepted Answer Pending Moderation
  1. Saturday, 8 December 2018 15:08 PM UTC
  2. PowerBuilder
  3. # Permalink

Evaluate is the easiest way to do this.  your function call (in your example) has to be a global function.  You also have all of the datawindow functions built in this way.

If you need something more complex, then you would have to write a parser in PB to build out a simple language or expressions builder of your own.   I have done a combination of these so that i have the ability to use datawindow functions, my own functions,  and application specific variables/values/settings.

Comment
  1. David Vasconcelos
  2. Sunday, 9 December 2018 17:28 PM UTC
Thanks for the response Mike. If all I have is a function call in a string variable for example variable = 'of_getdata()', what do I need to do/call to run the function.
  1. Helpful
  1. mike S
  2. Monday, 10 December 2018 18:06 PM UTC
make a global function - f_getdata() - and have it return a string. Then use evaluate:

ls_data = lds_ds.Describe( "Evaluate('" + ls_yourvariable + " ', 1)")
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 10 December 2018 21:03 PM UTC
  2. PowerBuilder
  3. # 1

Hi David;

    I would create a global function (GF) for this. In the GF you can dynamically instantiate various NVUO's ( see the Create Using syntax) and then also dynamically call its methods (see the Dynamic syntax option). The GF would then return a String of the result.

    Note that GF's can be called by DW objects to supply data to a column. So you could have the DWO call the GF and then use a GetItemXxxxx ( ) command to construct all of the message - "on the fly".

Food for thought.

Regards ... Chris

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