Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem using execscript
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01621618
Message ID:
01621649
Vues:
68
Any code defined in ExecScript goes away when ExecScript() completes so your class definition won't be there to be called when the event actually fires. THe script runs and ends, but the event happens after the script has long finished and that's why that doesn't work.

While you can call classes in ExecScript the lifetime is the key here - and in your case it doesn't work. You have to declare the class externally somewhere. You can *try* passing in a private variable that holds the reference to the class created (loHandler) and pass it out to the caller. That might work but I think in that case you end up locking the PRG file that ExecScript creates and you'll effectively have a memory leak with a class and PRG that never unloads.

+++ Rick ---

>Hi. In my app i have this situation:
>a form with a grid; this grid is designed at runtime using code saved in amemo field of a foxpro table using execscript() function. And up to here no problems.
>Every column of the grid can be doubleclicked and in the column1.text1.dblclick i call a method of the form passing to it the column1.controlsource. Obviously this method has to execute a code that depends from the code with which i designed the grid....My idea was to use in that code use a define class to create an objext to overwrite with bindevent ten code in form.method......When designing the grid i pass to the execscript some parameters and one of these is the form object that i use in the code...
>
>* example of execscript code
>lparameters xPar1, xPar2, oForm
>* code to design the grid
>Public oMyHandler
>oMyHandler = createObject("myHandler")
>
>=BidndEvent(oForm,"method",oMyHandler,"myClick")
>
>oForm.method("test")
>
>define class myHandler as session
>procedure myclick
>lparameter cControlSource
>messagebox(cControlSource)
>endproc
>enddefine
>
>This is an example code of the execscript and i if i insert after the bindevent function a call to the method, it works and it shows the name of the text i pass to the method....the problem is that when i return to the form and the execscript has ended the bindevent() has no effect.....
>
>
>i tried to delete the execution of the bindevent in the execscript and do it directly in the method receivinf from it the oMyHandler object, but without success because even if it is a public variable after the execution of the exescript code it is always .NULL. even if i define it the form.method (only public oMyHandler).
>
>someone has suggests....
>
>excuse me if my explanation is not so clear....
>
>thanks
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform