Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP 6 Debugging a form

Status
Not open for further replies.

eric43

Programmer
Apr 29, 2005
94
AU
In my app I see my main form with its pageframe entries and the controls thereon in the debugger.

As a test of a problem - I am opening a simple form with a command button on it from a command button on page 2 of the page frame.

I am surprised that I do not see this form as an object in the debugger.

The problem I am researching is trying to write back to the caption of a label on the form ( I have done this in other apps many times but I just can't crack this one).

The error says the form name cannot be found. As its not in the debugger I guess the two things must be linked.

Any one put me out of my frustration?


Eric
 
Eric,

Is the form an SCX file, and are you launching it from the command window? If so, you should be able to see it in the debugger, but it will appear under the name of the SCX file, not the Name property of the form (sorry if I'm stating the obvious).

If you are launching the form from code, is it possible that the variable holding a reference to the form has gone out of scope? For example, if you have DO FORM MyForm in a method, once you have come out of that method, there will no longer exist the MyForm variable which holds the reference to the form. The form might still be active, but it won't be visible in the debugger.

One solution is to use DO FORM MyForm NAME MyFormVar, and to make sure MyFormVar is either public or (better) a property of the calling form.

To go back to your original problem, if you are writing code on one control on a form, and that control needs to access another control on the same form, you shouldn't be referencing the form directly. You should be using THISFORM.

Hope this helps.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Geoff

Locals window has lots of other entries including my main form, some arrays and public variables.

Mike
I am loading the test form ( from a SCX file) from a cmd button on my main form.page2. I understand calling by the filename.

I tried DO FORM MyForm NAME MyFormVar using various words for MyFormVar - starting with MyForm - still not visible in locals. The form is of course viewable and workable on screen at this time.

I understand 'with thisform' but as I am going out to a prg I have to explicitly name the form holding the label I want to write to - this is where its all falling down. I can't get to the correct name of the form and can't inspect it in locals to give me the name actually used.

My expected name is in the Call stack ( this is why I am confused.

I have fashioned a workaround by saving the new entry(s) in an array from the prg and writing them to the form when I return to it.

Thanks for all your help

Eric
 

Eric,

I tried DO FORM MyForm NAME MyFormVar using various words for MyFormVar - starting with MyForm - still not visible in locals.

It's not the name of the variable that's important, it's the scope. Using the NAME clause is only profitable if the variable stays in scope after the click event of the button that launches it.

Look back at my previous post and check my comment about making the variable either public or a property of the calling form.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top