Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dynamically Add Code to a Method
Message
From
30/01/2003 18:31:28
Gerry Schmitz
GHS Automation Inc.
Calgary, Alberta, Canada
 
 
To
30/01/2003 10:22:46
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00747147
Message ID:
00747475
Views:
14
Yes, you can add code to a method at run time, or anywhere else to your app for that matter (VFP7).

Add a custom property to the object in question; eg: cScript = ""

In the method itself, add as appropriate:
IF !EMPTY( THIS.cScript )
   = EXECSCRIPT( THIS.cScript )    && or ... RETURN ... x = .... etc
ENDIF
Within the app, stuff the "script variables" as appropriate; eg.
<Object>.cScript = "THIS.BackColor = nnn" + CHR(10) + "<other statements>"
Note the use of a line feed (CHR(10)) to delimit statements.

These "scripts" can also be passed to Procedures and Functions to alter their behavior; eg
= My_Function( m.cScript )

and in My_Function ..

LPARAMETER tcScript

= EXECSCRIPT( tcScript )
You can also add a PARAMETER statement to a "script" and pass parameters at runtime; eg.
THIS.cScript = "LPARAMETER n1" + CHR(10) + "RETURN n1 ^ 3"

RETURN EXECSCRIPT( THIS.cScript, 5 )
All similar to Clipper 87 "code blocks" ... but only about 15 years after the fact.

Still waiting for "ragged arrays" .... etc.

(sigh)

>Is it possible to add code to a method on a grid during run time. The grid is based on a cursor and most of the properties are set in the grid 'init' method but it has also got code added to the 'when' event of each 'text1'.
>
>I am recreating this cursor within the program to refresh it with updated data and I can get it all to work okay by forcing a grid1.init() except that the code in the 'when' events seems to get lost.
>
>Is there any way I can write code to methods of the grid while the form is running. Any help gratefully appreciated.
>
>Thanks
>
>Sue Lacy-Jones
Previous
Reply
Map
View

Click here to load this message in the networking platform