Information générale
Catégorie:
Codage, syntaxe et commandes
>PUBLIC variables won't work when i call in the form. why is it that all the public variable that i declared in the main program will be missing in the form. here's my code.
>
>***Main.Prg
>PUBLIC oMyObject
>SET CLASSLIB TO myClass
>oMyObject = CreateObject("App")
>oMyObject.Init()
>DO FORM MyForm
>
>
>***MyForm.Scx
>
>*Init Method at myform.scx
>WAIT WINDOW oMyObject.MyText
>
The only thing I see wrong with your code is that you are calling oMyObject.Init() twice (once in the CreateObect, and once explicitely with oMyObject.Init())
I suggest you check these three things: 1) Check that you haven't done some sort of RELEASE, CLEAR ALL, etc. 2) Also, check that you haven't called another function with a reference to your object and that that function is not still executing - this will definetly cause a problem. 3) Check that your object has infact been created -- TYPE("oMyObject")="O"
This works for me - (and it's basically the same as you have done) So - the problem is not in the code you've posted.
***Main.Prg
PUBLIC oMyObject
oMyObject = CreateObject("TextBox")
oMyObject.Tag = "Here"
MyForm = CreateObject("MyFormClass") &&will run init and wait window
MyForm.Show()
DEFINE CLASS MyFormClass AS form
DoCreate = .T.
Caption = "Form1"
Name = "Form1"
PROCEDURE Init
WAIT WINDOW oMyObject.Tag
ENDPROC
ENDDEFINE
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement