Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing params (correct content)
Message
 
À
01/03/1998 10:30:20
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00081635
Message ID:
00082031
Vues:
33
>>>>Sawadee,
>>>>
>>>> I've tried passing params to a form by the book but I'm losing my way somehow. I'm trying to open a form from a control on another form. By doing DO FORM <> WITH p1, p2 and trying to catch them in the recieving form's Init, as the developer's guide outlines. But I get the error 'No PARAM statement in ...Click etc' The recieving form was built with the form wizard, so it is based on Form and has the wizstyle picbuttons attached to it. I want to instantiate this form in either Edit or New mode by telling it via the PARA. Somehow, the PARA statement in the Init of the launched form is not seen by the calling object's click event. Where have I gone wrong?
>>>>
>>>>Eric K.
>>>
>>>I think "Sawadee" is something like "hello, greetings..". Same to you. The form gets the parameters in init event (or in Load event if the form is a FP 2.x converted screen and windowtype prop 2 or 3) and those parameters are seen only in init (if not public). To make them visible in all form events and methods either assign them to public vars or to added custom form props.
>>>'No PARAM statement in ...Click etc' ?? Do you mean you call wizard buttons with params ? They don't have params.
>>>To instantiate it either in edit or new just pass it ass a param and click the appropriate button. As :
>>>
>>>..
>>>do form myForm with .t.  && ie: .t. for new
>>>
>>>* myForm.init         && Myform is built with wizard
>>>parameters lNewRecord
>>>if parameters() = 0
>>> lNewRecord = .f.
>>>endif
>>>if lNewRecord
>>>   thisform.picbtns1.cmdAdd.click
>>>else
>>>   thisform.picbtns1.cmdEdit.click
>>>endif
>>>
>>>Cetin
>>
>>Sawadee Kaap, (How are you today?)
>>
>> Actually, the param statement is in the formB Init, like the book says,
>>and in formA, the button ADD.Click contains DO FORM formB WITH p1, p2.
>>
>>By the way, how do you pass a logical data type?
>>
>>Eric Kleeman
>Hi Eric,
>The book ? Is it dev.guide ? Chapter 9, "passing parameters to a form" ? If so example is very short.
>- A form can have new properties to hold values, arrays, objects etc by adding via menu "form\New property".
>- These form properties could be seen by not only from any form PEM but also from another form's PEM that has a reference to this form (depending how the property is defined - public,prot. or hidden).
>- So when you pass params to a form (formB), if you want these params available to any form PEM, you assign them to custom form properties.
>- You could pass any type of params.
>
>
>*formA.cmdCallAnother.click  - a command button calling another with params
>*Pass object "thisform" reference, logical .t., char "New Caption"
>do formB with thisform, .t., "New Caption"
>
>* formB.init
>* Form has 2 custom props to hold first 2 values passed as params
>lparameters oCallerForm, lStatus, cFormCaption
>this.caption = cFormCaption
>this.oCallerForm = oCallerForm
>this.lStatus = lStatus
>
>* FormB.command1.click
>* If lStatus = .t. then change caller form's caption to "Yes" else "No"
>thisform.oCallerForm.Caption = iif(thisform.lStatus,"Yes","No")
>
>* Call another command button with params - in FormA
>thisform.oCallerForm.cmdButtonWithParams.click("FormB clicked me")
>
>*FormA.cmdButtonWithParams.click
>lparameters cWhoClickedMe
>wait window nowait cWhoClickedMe
>
>Cetin

Hello Again,

I found my problem. The forms in this case are based on a class contained in a vcx then turned into a project form using New/New Form and dropping the form class from the toolbar. Problem is, I forgot to remove the formset after removing the default form1 from the form designer. So, while reading about PARAMETERS, it makes the statement "It must be the first executable statement in the called object". Since it actually is a formset, the formB Init is not first,
formsetB Init is first. Just another case of proceduralitis on my part.

Thanks for the tip on passing the THISFORM reference.

Eric Kleeman
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform