Subject Re: calling part of .wfm from another .prg
From Akshat Kapoor <akshat.kapoor@kapoorsons.in>
Date Thu, 30 Dec 2021 12:29:51 +0530
Newsgroups dbase.getting-started

Good morning Milind,

> 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?

Others have given wonderful explanation I am not going into those details.
I a just describing what I do.

When I require the same function in multiple forms I place it in the
custom form on which all my forms are based.

The other option is placing it in a procedure file.

The third and least used way is

set procedure to e_label.wfm
e_labelform::save_item()

This will execute the save_item() function saved in e_label.wfm

And yes it does require modifications to address issues related to
accessing data/memory variables.

Warning :

When I execute
set procedure to e_label.wfm
e_labelform::save_item()

from e_purch2.wfm and e_labelform::save_item() there is a line
form.add_item.value  = 45
then it will change the entryfield add_item of e_purch2.wfm and not
e_label.wfm as 'form' will refer to current form.

Hence this requires special care and planning.

Regards
Akshat