General information
Category:
Coding, syntax & commands
>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
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only