Subject |
Re: Simple parameter passing |
From |
Mervyn Bick <invalid@invalid.invalid> |
Date |
Wed, 28 Jan 2015 09:06:15 +0200 |
Newsgroups |
dbase.getting-started |
Attachment(s) |
Unnamed File 1, Unnamed File 2, Unnamed File 3, Unnamed File 4, firstform.wfm,
Unnamed File 6, Unnamed File 7, firstform1.wfm, Unnamed File 9, Unnamed File 10,
firstform2.wfm, Unnamed File 12, Unnamed File 13, Unnamed File 14 |
|
| On Wed, 28 Jan 2015 03:23:38 +0200, Randy Waldman <randwald@comcast.net>
wrote:
> Hi. The mention of 'parameters' in Ken's book is overwhelming. All I
> want to do is "call a form (from an onclick of a form) and pass a
> parameter to a sql on the 2nd form.
>
> Can someone shortcut the learning curve for me?
There are two ways of doing this.
The first way is to let the first form load the second form into memory
and create an instance of it. Now you can change properties of objects in
the second form and when you are satisfied you can then useopen() (or
readmodal()) to launch the second form. Normally a form does not have a
parent but if you set the first form as the second form's parent you can
easily write values back to the correct parent form no matter how many
copies of the first form are open.
The second way, which is preferred by OOP "purists" but takes more effort,
is to DO the second form WITH parameters. A standard form only has code
to deal with a single logical parameter which is used to determine whether
the form uses its open() or readmodal() method to launch it. This means
the second form has to have code in it to handle the additional
parameter(s). The easiest way to do this is to copy the "bootstrap" code
from the form into the header section and then modify it. It is important
to add a "RETURN" after this modified bootstrap otherwise dBASE will
simply execute the original bootstrap nullifying the whole exercise.
The second way is more in keeping with the idea of OOP programming but it
does require more effort especially if you need to pass values back to the
calling form. findinstance() can find the parent form for you but a
problem arises if more than one instance of the parent form can be open at
the same time. You then need code to enable the child to find the correct
copy of the first form. It's not particularly difficult but let's leave
this until later.
Mervyn.
|
|
|
|
|
|
|
|
|
|
|