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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get name of calling program

Status
Not open for further replies.

113983

Programmer
Jul 28, 2008
26
I have a generic form where I allow operator to set a flag of do not show this message again. This form can be called from a number of other forms. Is there any way to find out the name of the calling form? I could put it in a _screen property or a public but then I have to change a number of programs so was hoping that VFP stored the calling program name somewhere.
 
Do you want to find the name of the calling form, or the calling program (as per the heading in this thread)?

Dave's suggestion of using SYS(16) will give you the name of the main program, that is, the root of the calling stack.

If you want to know which form calls the current form, you will have to pass that as a parameter. There are several ways of doing that, but the easiest is probably to pass THISFORM.Name from the caller. In other words:

Code:
* In callling form:
DO FORM GenericForm WITH THISFORM.Name, <other parameters>

....

* In Init of GenericForm
LPARAMETERS tcCaller, <other parameters>

If this doesn't answer your question, perhaps you could clarify what you are trying to do.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
How is that dependant on the caller? Wouldn't you store the "do not show this message again" together with the message that should not be repeated, instead of the caller?

Bye, Olaf.
 
How does this depend on the caller? Wouldn't you store the "do not show this message again" flag together with the message that should not be repeated, instead of remembering the calleing program?

Or wouldn't it also be depending on the user? ID() would give you that for example.

The progam name of the calling program is indeed SYS(16,PROGRAM(-1)-1). Or you can get the whole stack of calls at any time the via AStackInfo().

Bye, Olaf.
 
Hi,

I would set in the calling form a property lDontshowMessageBox to .T. and not in the MessageBoxForm.
This setting can be done upon return to the calling form.
Messagebox should only be shown when ThisForm.lDontshowMessageBox = .F.

Regards,

Jockey2

 
Hi Mike - it was the calling form and I found that I could use _screen.activeform.name to get that name before calling the next form or program. I also looked at the astackinfo() as it has list of programs run. I decided not to make program change as over 100 forms affected by this so changed the message I display to be more generic.

Thanks for the help.
 
Hi Olaf - I didn't see your post when I responded - that is a good tip and may get me what I want.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top