>
> * your code here
>
> Steve
>
> > In my quest for doing away with public variables, I have created a form which has properties created where local variables are stored. I have created a method called getvar, which retrieves variables from the properties like
> >
> >
gddate=thisform.gddate
> > gnmonth=thisform.gnmonth
> >
> > etc.
> >
> > Whenever required I need to retrieve the variables from this method by calling thisform.getvar()
> >
> > However, the variables are not retrieved, with errors obtained like "gddate not found" after issuing this command
>
> I think you may be misunderstanding something here. If the values are stored as properties on the form then you do not need to create methods to access them (you can if you wish, but you don't need to).
>
> Assuming you have your property "gdDate" and want to access its value in the code in the click of a button, all you need to do is this:
>
>
LOCAL ldDate
> ldDate = ThisForm.gdDate
> *** Now use ldDate any way you wish
>
> If you want to use a method, then in your method you must return the value:
>
>
*** FORM::GetVars Method
> LPARAMETERS tcVarName
>
> *** Does this property name exist
> IF PEMSTATUS( This, tcVarName, 5 )
> luRetVal = EVALUATE( "ThisForm." + tcVarName )
> ELSE
> luRetVal = NULL
> ENDIF
> RETURN luRetVal
>
> Now you would have almost the same code in the click of your button as before, but this time you would call the method:
>
>
LOCAL ldDate
> ldDate = ThisForm.GetVars( 'gdDate' )
> *** Now use ldDate any way you wish
>
> Does that help at all?
>
> Regards
> Andy Kramek
> Microsoft MVP (Visual FoxPro)
>
Tightline Computers Inc, Akron Ohio, USAHi Andy,
Well, recalling up to 10 variables could be quite thready, especially when the process is repetitive. Hence I had selected the method. However in the final line of your code, if you have to command
ldDate = ThisForm.GetVars( 'gdDate' )
, then it is as good as
lddate=thisform.lddate
, which also involves a lot less coding, isn't it?
Thought I'll use this opportunity to post you another question. Since access to a variable is now designated to a property value, does this mean that when a variable created by a user interface, and through a control has changed, does it have to be physically reinstated into the form's property value every time it changes?
Thanks a lot, and best regards,
Steve
Regards,
Steve