Subject Re: Control passing back and fro in a form sub routine
From Mervyn Bick <invalid@invalid.invalid>
Date Wed, 26 Jul 2023 11:19:31 +0200
Newsgroups dbase.getting-started

On 2023/07/26 07:33, Akshat Kapoor wrote:

> Passing control to square.prg is no issue. Passing value back to form is
> also not an issue. But passing value back to the form in between is an
> issue.
>
> You can say
> Form.text1.text = square(X)
> The value returned by square.prg will be displayed. I am posting code
> BUT it may cause complications due to use of Public variables.
>
>      Public mform
>      mform = form
> What happens to form after the end of the form is untested. It will be
> released from memory or not I cannot say.

The use of Public variables, and user-defined properties of the _app
object which are their counterpart in OOP, has it's place but one should
really only use them as a last resort when there is no other way.

Back in the early days of dBASE provision was made for functions and
procedures.  Functions returned a value.  Procedures didn't return a
value but the code could assign values to various variables.  Over the
years the distinction has become blurred and functions now serve both
purposes.

In days gone by, when I was learning to program, the buzz word was
"Structured" programming.  In effect, don't use dBASE procedures and
functions should only have one entry point and one exit point.  I must
admit though that there are occasions where I stray from the narrow path
as a matter of expediency.

Mervyn.