Subject Re: calling part of .wfm from another .prg
From Bruce Beacham <bbeacham@no-plm-lowman.co.uk>
Date Mon, 3 Jan 2022 22:47:58 +0000
Newsgroups dbase.getting-started

Not good.

If you open the form in the ordinary way (rather than from another form
or function), it will still see and use the public variable, whereas you
actually want it to use the properties of its own form.

You should read-up about encapsulation.


Bruce

On 02/01/2022 16:12, Milind Nighojkar wrote:
> Thanks Bruce,
> It worked with minor change insted of Parameter fm. I used public fm
> Regards
>
>
> Bruce Beacham Wrote:
>
>> Pass a parameter when you call the method form_onOpen from another
>> function, another form's method.
>> Then in the function form_onOpen you test for the type of the variable
>> 'form'.
>> If it is not known, then the parameter is the object (usually another
>> form) which carries the properties you wish to retrieve.    If it is
>> known, then your alternative route is ignored.
>>
>> Thus:
>>
>> FUNCTION form_onOpen
>>
>> parameter fm                // this will be a private variable.
>>
>> if type("form") = "O"
>>         fm = form
>> endif
>>
>> nCol = fm.grid1.currentcolumn
>>
>> ....and so on.
>>
>>
>> Bruce Beacham
>>
>> On 29/12/2021 17:39, Milind Nighojkar wrote:
>>> Scenerio:
>>> There are few .wfm statements in    function GRID1_onOpen()
>>> nCol = form.grid1.currentcolumn
>>> m_COL_name = 'COLUMN'+ltrim(rtrim(str(1)))
>>>
>>> Want to call these 2 statements from external .prg say temp.prg
>>>
>>> Issue seen
>>> When temp.prg is called in  function GRID1_onOpen() get error message saying 'variable form not defined'
>>>
>>> Any suggestions?
>>>
>>> Milind Nighojkar
>