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

Form parameter problem (passing 2 parameters)

Status
Not open for further replies.

FoxEgg

Programmer
Mar 24, 2002
749
AU
This "Form parameter problem" is a follow on from a post in 2003... (Who said we were fast down here in the Deep South...) which is in thread184-577518

In that thread, Mike Gagnon explained the firing sequence which to mere mortal me made no sense at all... but that is life.

Helpful Member!mgagnon (Programmer)
16 Jun 03 19:20
aharrisreid

The sequence seems to be Load of the form, init of the pageframe and then init of the form, so pass the value to the load of the form.

Mike Gagnon

and suggested a solution...

In answer to ...
wgcs (Programmer)
16 Jun 03 20:08
"There is no way to pass the value to the Form's Load event..."


Mike said (and excuse me, Mike, for paraphrasing....)

I beg to differ on that. Use :
Var1 = "12"
do form myForm with var1


In the load of the form, calle the init() of the form with the var1 as a paramater.

Load of the form
thisform.init(var1)

Init of the form:
Lparamater lcVar1
messagebox(lcVar1)

And doing this changes the sequence of loading the form, and the init of that pageframe comes after the form's init().

Mike Gagnon


I had this problem with passing parameters with the pageframe too... and didn't have enough cortical RAM to work it out properly so I used a messy work-around solution...


The question I have now is how do I pass TWO parameters to the init....

FoxEgg
 
Thanks Mike... but I am not sure I grasp your meaning...

Isn't this already using a 'parameter object'

Init of the form:
Lparamater lcVar1
messagebox(lcVar1)

The issue is: how do I redirect 2 parameters to the init event when there is a pageframe..

Cheers

JF
 
The pageframe activate should also have an additional Form Property called FIRSTTIME. Initialize this as FALSE when you create the Property. You will set it as TRUE on form init(). Since the pageframe wants to init first the form property should take the default of .f. and nothing will happen. After the init of the form is completed the Activate of the pageframe should fire and everything should work as expected.

In the INIT() of the FORM
Thisform.FirstTime = .T.

** not tested but should get you close.



Don Higgins
 
FoxEgg,

The parameters automatically get passed to the Form object's init event whether you are using DO FORM WITH or using something like CREATEOBJECT(). As far as I know, the only time that parameters ever get passed to the load event is when you are dealing with a FORMSET object, which I don't think you have here (judging by what you've said). Try running the following code and you'll see that parameters sent to a form are sent to the INIT, having a pageframe on your form doesn't change this...
Code:
LOCAL lcParam1, lcParam2, loForm
lcParam1 = "This is Parameter 1"
lcParam2 = "This is Parameter 2"
loForm = CREATEOBJECT("MyForm", lcParam1, lcParam2)
loForm.Show(1)

DEFINE CLASS MyForm as Form
	ADD OBJECT Pageframe1 as Pageframe WITH ;
		left = 0, top = 0, width = 200, height = 200, ;
		pagecount = 2, Visible = .T.

	PROCEDURE Init
		LPARAMETERS tcParameter1, tcParameter2
		MESSAGEBOX(tcParameter1)
		MESSAGEBOX(tcParameter2)
	ENDPROC
ENDDEFINE

The same would happen if you had a form file MyForm.scx and did the following...
Code:
DO FORM MyForm With lcParam1, lcParam2

boyd.gif

SweetPotato Software Website
My Blog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top