Subject Re: indexing problem
From Charlie <trainman@traincity.com>
Date Mon, 18 Jul 2016 02:25:29 -0400
Newsgroups dbase.getting-started

Hi Mervyn,

We discussed this last week below in this thread.

I have to declare two different indexes for different circumstances as explained last week.

The only way I have found to get around this problem so far is to have two different identical forms with two different indexes declared.

This is awkward because it is going from an xdml program to a oodml form.

I have tried the following with no luck:

1.  Declaring a parameter in the bootstrap.  I can't figure out how to do this as there is a parameter declared in the form below the bootstrap which seems to interfere.  I have gotten around this be declaring the variable public in the xdml program and it has always seemed to work with xdml and since the form hasn't been defined in the bootstrap I think it should work but I know public is not good in oodml.  (The variable that I am trying to define is the index name for different situations.  I've tried defining this in the xdml program.

2.  I cannot figure out how to define the index in the bootstrap because the form has not been defined.  I get an error form not defined or something like that.

Possibly what I am trying to do is not possible because of the xdml program.  If that's the case I'll just leave as is because it works well with the two almost identical forms.

If possible I'd like to eliminate the two identical forms for one that is more proper if possible.

Let me know what you think.

Charlie

Mervyn Bick Wrote:

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