Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
PUBLIC variables won't work when i call in the form
Message
From
16/01/2002 10:02:00
 
 
To
15/01/2002 18:04:33
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00604937
Message ID:
00605371
Views:
26
>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
Map
View

Click here to load this message in the networking platform