Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing parameters to generalised prompt/edit form
Message
 
 
To
11/02/2002 06:29:54
John Faithfull
Hunterian Museum, University of Glasgow,
Glasgow, United Kingdom
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00618212
Message ID:
00618252
Views:
22
This message has been marked as the solution to the initial question of the thread.
>Hello folks,
>
>It's a few months since I did any VFP programming, and I'm feeling pretty dim.
>
>I want to create a simple form which will allow the value of any variable to be displayed and/or edited. There are two parameters, the variable name, and a caption for the form. eg
>
>do form "editvar.scx" with "dInitdate", "Enter the starting date"
>
>Will allow the user to see the current value of dInitdate, and edit it if desired.
>
>The parameters cVarname and cCaption are passed as lparameters to the Init event of the form.
>
>Two questions:
>
>(1) How do I display the current value of the variable in a Text Box (eg dInitdate in the above example)? I've tried various variations on
>
>dCurVal=evaluate(cVarname)
>
>without consistent success.
>
>(2)Secondly, once changed, how do I update the value of the original variable when the OK button is pressed? &cVarname=dCurVal seems to work in the command window, but gives an error in the Click event of the button.
>
>Can anybody help, or point to some existing example which will carry out the same function? Ideally, for any variable whether date, character or numeric...
>
>Apologies if this is not very clearly expressed...
>
>Thanks
>

John,
One of the drawbacks I see with this, is you can only process variables that are private or global in scope. If the variables are local in scope, they will not be available in the form.

I recommend modifying your approach slightly. Instead of passing the name of the variable, pass an object with a couple of custom properties.
define class SesParam as Session
cVarname=(space(0))
uVarOldValue=.NULL.
uVarNewValue=.NULL.
cCaption=(space(0))
enddefine
Create the object in the calling routine. Set the properties and pass it to EditVar.scx.
loparam = createobject('sesparam')
With loparam
   .cVarName = 'dInitdate'
   .uVarOldValue = dInitDate
   .cCaption = 'Enter the starting date'
Endwith
do editvar.scx with loparam
dInitdate = loparam.uVarNewValue
In the Init of the form, store the passed reference to a property of the form. Set the value of the textbox to uVarOldValue. In the OK button click, set the value of uVarNewValue. Because the object was passed by reference, you simply have to process loparam on return.

HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform