Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Programmatically changing Events at runtime
Message
From
21/07/1999 18:44:56
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00237998
Message ID:
00244444
Views:
17
>>>Can you programmatically change a Double-Click event at runtime?
>>
>>No. If you find that you need to do this, most normal situations can be handled wiha a CASE statement in the event. If you cannot handle, it this way, you probably need to rethink hte design.
>
>Since all VFP code is interpreted, I believe that you can create events like this. In fact, I have. You just need someplace to stick the name of the routine to invoke, such as in the .tag property of the textbox, or in a custom property if you want to create one.

This is not changing the textbox's code. I never said that a single routine can't decide which routine to call based on certain conditions, in fact, this is exactly what I did say.

The method you proposed is actually pretty commonplace (well, key parts of it anyway). I have several times had the need to pass the name of a method or routine to a function so that function can call the routine I passed. (Parameters are the key difference here... I rather detest global variables of _any_ sort). My implementation might go something like this:

Command1.Click
THISFORM.RunMethod("SomeCustomMethod")

Form.RunMethod
LPARA tcMethodToRun
cMethodToRun = "THISFORM." + tcMethodToRun + "()"
RETURN EVAL(cMethodToRun)

This is also used in more than one web framework, where the name of server class method to run is determined from a variable passed in the URL.


Keep in mind the original poster didn't need anything like this at all. All he really needed was a way to get code into a grid's textbox at run time- wihch is best accomplished by replacing that textbox with one from a specified class at runtime.
Erik Moore
Clientelligence
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform