Example
u_nv_dynamic nv_dynamic
string sz_object
// Example sz_object = "u_nv_dynamic_copy"
sz_object = message.stringparm
nv_dynamic = CREATE USING sz_object
nv_dynamic.uf_Process()
DESTROY nv_dynamic
By doing this I can dynamically link in any code I want. All object must be
inherited from u_nv_dynamic. u_nv_dynamic must have a method uf_Process.
It actually works really well.
---
Dean Jones, CPD Professional
PowerTeam, Inc.
www.powerobjects.com
de...@powerobjects.com
Chad Bradley wrote in message ...
>I have simple code:
>
>string ls
>
>ls = "f_copyfile('C:\autoexec.bat' , 'c:\temp')"
>
>Is there a way in powerbuilder to execute that string?
>
>If not, how can I accomplish the same task without making some enormous
CASE
>statement in another function?
>
>Chad Bradley
>
>
Geert 'Darling' Van Damme
Chad Bradley wrote in message ...
Dean Jones wrote:
> The only way to dynamically run code is to abstract out the common
> behavior
> into an ancestor object. Create descendent objects to handle specific
>
> processing and then create the object using CREATE USING command.
>
> Example
>
> u_nv_dynamic nv_dynamic
> string sz_object
>
> // Example sz_object = "u_nv_dynamic_copy"
> sz_object = message.stringparm
>
> nv_dynamic = CREATE USING sz_object
>
> nv_dynamic.uf_Process()
>
> DESTROY nv_dynamic
>
> By doing this I can dynamically link in any code I want. All object
> must be
> inherited from u_nv_dynamic. u_nv_dynamic must have a method
> uf_Process.
> It actually works really well.
>
> ---
> Dean Jones, CPD Professional
> PowerTeam, Inc.
> www.powerobjects.com
> de...@powerobjects.com
>
> Chad Bradley wrote in message ...
> >I have simple code:
> >
> >string ls
> >
> >ls = "f_copyfile('C:\autoexec.bat' , 'c:\temp')"
> >
> >Is there a way in powerbuilder to execute that string?
> >
> >If not, how can I accomplish the same task without making some
> enormous
> CASE
> >statement in another function?
> >
> >Chad Bradley
> >
> >
--
Mahendra Dhamdhere
Unicef, New York
Email:mahe...@hotmail.com
This allows us to dynamically execute functions based based on the class
instantiated at run-time. HTH.
--kirk
Mahendra Dhamdhere <nospam_m...@hotmail.com> wrote in article
<358136BE...@hotmail.com>...
Regards,
Mason Liu
Object Labs, Inc.
There is a quick hack which you can use to do macro substitution. Make sure
your function is a global function (not in an NVO).
Then create a datastore with some bogus external source (ie. a datawindow
with 1 column of any type).
Insert one row into the datastore and follow the below example, using your
global function.
Here is an example of how the code would look:
datastore lds
string ls
ls = "f_copyfile("+"~"C:\autoexec.bat~" , ~"c:\temp~")"
lds=CREATE datastore
lds.dataobject="dw_bogus"
lds.insertrow(0)
lds.Describe( "Evaluate('"+ls+"', 1)")
DESTROY lds
Regards,
Brad Gawne
bga...@ibm.net
----------------------------------------------------
COPIED FROM ONLINE HELP
-----------------------------------------------------
Evaluating an expression Describe's Evaluate function allows you to
evaluate DataWindow painter expressions within a script using data in the
DataWindow. Evaluate has the following syntax, which you specify for
propertylist.
Evaluate ( 'expression', rownumber )
Expression is the expression you want to evaluate and rownumber is the
number of the row for which you want to evaluate the expression. The
expression usually includes DataWindow painter functions. For example, in
the following statement, Describe reports either 255 or 0 depending on the
value of the salary column in row 3:
ls_ret = dw_1.Describe( &
"Evaluate('If(salary > 100000, 255, 0)', 3)")
You can call DataWindow control functions in a script to get data from the
DataWindow, but some painter functions (such as LookUpDisplay) cannot be
called in a script. Using Evaluate is the only way to call them. (See the
example Evaluating the display value of a DropDownDataWindow below.)
-------------------------------------------------------------------------
Dean, I actually do have this method implemented and it does work well, but
it is getting insane having to have another object just to call a method in
another object.
This is one of the most irritating things about PowerBuilder not being 100%
Object Oriented. (Another is not being able to overload functions ONLY by
the return type...)
Chad Bradley
Dean Jones wrote in message ...
>The only way to dynamically run code is to abstract out the common behavior
>into an ancestor object. Create descendent objects to handle specific
>processing and then create the object using CREATE USING command.
>
>Example
>
>u_nv_dynamic nv_dynamic
>string sz_object
>
>// Example sz_object = "u_nv_dynamic_copy"
>sz_object = message.stringparm
>
>nv_dynamic = CREATE USING sz_object
>
>nv_dynamic.uf_Process()
>
>DESTROY nv_dynamic
>
>
>By doing this I can dynamically link in any code I want. All object must
be
>inherited from u_nv_dynamic. u_nv_dynamic must have a method uf_Process.
>It actually works really well.
>
>---
>Dean Jones, CPD Professional
>PowerTeam, Inc.
>www.powerobjects.com
>de...@powerobjects.com
>
of_foo(integer ai_no) returns string
of_foo(integer ai_no) returns boolean
Which one gets called when I execute this.of_foo(100)?
Regards,
Dave Fish [Team PS]
Application Design Specialists
Sydney, Australia
On Wed, 1 Jul 1998 12:41:58 -0500, "Chad Bradley"
<cbra...@solarc.com> wrote:
>Thanks for all the replies.
>
>Dean, I actually do have this method implemented and it does work well, but
>it is getting insane having to have another object just to call a method in
>another object.
>
>This is one of the most irritating things about PowerBuilder not being 100%
>Object Oriented. (Another is not being able to overload functions ONLY by
>the return type...)
>
>Chad Bradley
>
>
>How would it be useful to be able to overload a function only by the
>return type? How would the runtime engine "know" which function to
>call? For example:
>
>of_foo(integer ai_no) returns string
>of_foo(integer ai_no) returns boolean
>
>Which one gets called when I execute this.of_foo(100)?
As you wrote it, it doesn't matter which was called does it? [The
assumtion being that if they have the same name, they do "essentially"
the same thing.]
The compiler (at least a very smart one) could probable deal with:
string s
s = of_foo(17)
and
boolean b
b = of_foo(17)
but the more interesting case is:
string s
s = string(of_foo(17))
Regards, Mike Niemann, PBBrowser Author
Simon
Dave Fish [Team PS] wrote in message
<359b7764...@forums.powersoft.com>...
>How would it be useful to be able to overload a function only by the
>return type? How would the runtime engine "know" which function to
>call? For example:
>
>of_foo(integer ai_no) returns string
>of_foo(integer ai_no) returns boolean
>
>Which one gets called when I execute this.of_foo(100)?
>
Regards,
Dave Fish [Team PS]
Application Design Specialists
Sydney, Australia
On Thu, 02 Jul 1998 23:59:21 GMT, mnie...@oowidgets.com (Mike
Niemann) wrote:
>On Thu, 02 Jul 1998 20:51:20 GMT, df...@bigpond.com (Dave Fish [Team
>PS]) wrote:
>
>>How would it be useful to be able to overload a function only by the
>>return type? How would the runtime engine "know" which function to
>>call? For example:
>>
>>of_foo(integer ai_no) returns string
>>of_foo(integer ai_no) returns boolean
>>
>>Which one gets called when I execute this.of_foo(100)?
>