How to Change a Method at Run Time
ID: Q141076
|
The information in this article applies to:
-
Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b
SUMMARY
All methods are read-only at run time. You can, however, have several
methods and decide at run time which method to execute. This article shows
you how.
MORE INFORMATION
Step-by-Step Example
- Create a new form.
- Place a command button (Command1) on the form, and add the following
code to its Click event:
lcTemp=ThisForm.gcCurrentclk
&lcTemp
- Place an Option Group on the form, and add the following code to its
Click event:
IF This.Value=1
ThisForm.gcCurrentclk="ThisForm.Click1"
ELSE
ThisForm.gcCurrentclk="ThisForm.Click2"
ENDIF
- Create a new form property called gcCurrentclk, and assign
ThisForm.Click1 to gcCurrentclk.
- Create a new Form method called Click1, and place the following in the
Form.Click1 method:
WAIT WINDOW "Click #1"
- Create a new method called Click2, and place the following code in the
Form.Click2 method:
WAIT WINDOW "Click #2"
- Run the form.
The option group determines which Click method for the command button will
execute.
NOTE: The Click event for the command button does not have to be a method
of the current form. For example:
gcCurrentclk="DO myprog.PRG" would execute a program.
gcCurrentclk="oMyclass.Click1" would execute a method of an external class.
gcCurrentclk="WAIT WINDOW" would execute a wait window.
Additional query words:
VFoxWin
Keywords : FxprgGeneral
Version : WINDOWS:3.0,3.0b
Platform : WINDOWS
Issue type :