Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
FAQ ID: 7967 Comment
Message
De
06/03/2009 15:45:32
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Divers
Thread ID:
01386198
Message ID:
01386316
Vues:
146
>Summary: In order to create a more flexible grid, some developers choose to build the grid's columns and controls at run-time. But since you can't add code to events and methods at run-time, you've got a bit of a dilemma.

You can "add" code at run-time in a method or an event. Have the event execute an external procedure -- call it in the method or event code. In the event or method that you want to have code defined at run-time, enter the following:
DO GetExternalUserExit WITH 'ExternalUserExit001"
Now define an UDF that is named GetExternalUserExit.prg with the following code:
FUNCTION GetExternalUserExit
LPARAMETERS pcExternalUserExit
SELECT codetable
LOCATE FOR funcname = pcExternalUserExit
IF FOUND()
   STRTOFILE(ALLTRIM(codetable.code),pcExternalUserExit+".prg")
   DO (pcExternalUserExit)
ELSE
   WAIT WINDOW "ERROR -- UDF Not defined"
ENDIF
Then create a table that has the following two columns:

Field Name Type
-------------------------------
FuncName C(40)
Code Memo

Then add the value "ExternalUserExit001" to the codetable.funcname field and the following code to the codetable.code field:
FUNCTION ExternalUserExit001
WAIT WINDOW "My Runtime User Exit"
ENDFUNC
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform