Subject |
Re: indexing problem |
From |
Mervyn Bick <invalid@invalid.invalid> |
Date |
Mon, 11 Jul 2016 08:42:09 +0200 |
Newsgroups |
dbase.getting-started |
On 10-Jul-16 11:32 PM, Charlie wrote:
> Thanks.. That is interesting.
>
> I have another semi problem. I figured a way around it but I don't think it is proper.
>
> I am going from a program to a form.
>
> If x = 1 set index to z
>
> if x = 2 set index to y
>
> I got by this by making another identical form except for the index. But this make it much more messy.
>
> Is there a way to index a form in some sort of a command from a program??
Yes there is.
In XDML
SET ORDER TO tagname
GOTO TOP
to return to natural order
SET ORDER TO
GOTO TOP
In OODML
form.queryname.rowset.indexName := tagname
form.queryname.rowset.first()
to return to natural order
form.queryname.rowset.indexName := ""
form.queryname.rowset.first()
Using := instead of = to assign the tagname will help to pick up typos
as it will give an error when you save the form rather than waiting
until you run the form.
A fairly common way to change the index is to use the onChange event
handler of a radiobutton on a form.
function RADIOBUTTON1_onChange
if this.value = true
form.queryname.rowset.indexName := tagname1
form.queryname.rowset.first()
// SET ORDER TO tagname1 //for XDML
// GOTO TOP
endif
return
function RADIOBUTTON2_onChange
if this.value = true
form.queryname.rowset.indexName := tagname2
form.queryname.rowset.first()
// SET ORDER TO tagname2 //for XDML
// GOTO TOP
endif
return
If you are using XDML to access your table don't forget to close the
table when the form closes. OODML does this automatically but you will
need to do this yourself for XDML.
function form_onClose
use
return
Generally speaking, you should never need to have identical, or almost
identical, forms (or reports for that matter) where the only difference
is the rowset and/or some of the text.
dBASE forms and reports are created as classes. A class is effectively
a blueprint and you can make as many instances (copies) of it as you
need. The designers place "bootstrap" code at the top of every form or
report just above the class definition which loads the class into
memory, creates an instance and then opens, or renders, the class.
There is nothing to stop you from placing your own "bootstrap" in the
heading area of a form where it is safe from being changed by the
designer. This code can be written to accept a parameter which can then
be used to determine what table(s) to use and what text to change before
the form is run.
Mervyn.
|
|