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