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!

Howto use the main VFP-window and my own menu?

Status
Not open for further replies.

RedLion

Programmer
Sep 13, 2000
342
NL
Hello,

I would like to use the main VFP-form to use for myMenu. I've got a main.prg that first calls the login procedure, when that's done it should call the main VFP form with myMenu.

But when I do this I get an error when I call myMenu.
Error:
Invalid subscript reference

MyMain.prg
&& ...Declaring things like the oSettings Object

&& Log the user in to the system
DO FORM oSettings.getMapForm() + "loginBack"

&& After logged in, Activate the myMenu.mpr in the main VFP window

DO oSettings.getMapOther() + "mnuHoofd.mpr"

&& When the user ends the program by using the menu File - Close
QUIT


What am I doing wrong here? Should it be done on an other way?


Thanks,

Charl
 
Please, tell which line of code exactly causes mentioned error message. Probably you should replace following command

DO FORM oSettings.getMapForm() + "loginBack"

by following:

DO FORM (oSettings.getMapForm() + "loginBack")

Same for DO (take expression into '()')



Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
When you say main VFP form do you mean the screen. Or some form that you are using instead?
-Pete
 
Sorry for my bad information.

When I make a call for the menu:

DO oSettings.getMapOther() + "mnuHoofd.mpr"

I get the error.

When I call the menu by the real pad it gives the same error. When I call it by the command window it works, but it only replace's the menu balk, and then just goes futher with VFP, so it seems that I use the screen (VFP) on the wrong way? When I immediately call a child-form instead of only the menu balk, and in the init of that form the menu it works so as it has to work, but I don't want to have a startup form.

What's wrong here?

Thanks,

Charl


 
First of all, try to use
DO (oSettings.getMapOther() + "mnuHoofd.mpr")
Are you sure oSettings object contains that method (getMapOther) and is available ata that time?

As about menu, you should look into mnuHoofd.mpr file and see what code generated by VFP. You will learn a lot from there about how menu defined in VFP and how it is activated. In Help you will find descriptions of all commands there.

Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Yuu might also try hard coding the menu. See thread thread184-22683


-Pete
 
Hi Vlad,

I've tried to use '(' but it didn't make a difference. And oSettings does it all right. when I type:
Do "D:\MON\mnuHoofd.mpr"
(the place where the file is, the same result as oSettings gives) It isn't working. And when I use the code:
Do "D:\MON\mnuHoofd.mpr"
In the command window it works all right, but not when I call it from a .prg file.



So I think the question has to be: Is it possible to call a menu from a .prg file which calls the main VFP-form?


by the way, when I use the menu in an other program the menu works fine, but then it is called from a myForm.
 
Answer: yes, you can run menu file from prg file. We do this in our application many times. Just need to locate exactly the source of error. Are you sure you get error in that line? Maybe it is inside of MPR file. The DO command seems ok.
Invalid subscript reference error appears usually when working with arrays or trying some commands that foul VFP to think that they work with array, when they just are calls to functions.
Try to debug PRG file step by step accurately and see exact line where error occurs.

Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top