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

Hi Mervyn... OK I'm starting to get it thanks.

I am confused though.  You have either with cindex1 or cindex2 and then the parameter is cindexname.  I don't understand that part of it.  How did it go from cindex1 or 2 to cindexname?

BTW I think I was confused on what the bootstrap is.  

Thanks.

Charlie

Mervyn Bick Wrote:

> On 18-Jul-16 8:25 AM, Charlie wrote:
> > 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.
>
>
> The bootstrap code in a form is written so that one can pass a logical
> value to it.  Passing true to it
>
>     eg  DO MyForm.wfm with true
>
> causes it to open modally.  If no parameter or is passed or false is
> passed the form opens normally.  No provision is made for additional
> parameters.  Any changes made to this code get overwritten when the
> designer streams out code after any change in the form layout.
>
> Instead of using the built-in bootstrap one can, however, write one's
> own in the Header section of the form.  Any code here is safe from
> attack by the designer.
>
> A variable is created as a logical false value if one doesn't assign any
> value to it.  The default bootstrap in a form does not, therefore, have
> a problem if no parameter is passed.  It sees bModal as false and opens
> the form normally.
>
> In this case we need to pass a character string containing the
> indexName.  If you don't pass a string dBASE will get upset at having to
> deal with a logical value.  It is, therefore, necessary to test for a
> string and only set the index if the parameter has been passed.
> ArgCount() counts the number of parameters passed.
>
> Add the code below to the header section of your OODML form.  Then, from
> your XDML form something like
>
>     cIndex1 = "whatever"
>     cIndex2 = "other"
>     if nForm = 1
>        DO myForm.wfm with cIndex1
>     else
>        DO myForm.wfm with cIndex2
>     endif
>
>
>   From the Command Panel you would launch the form with
>
>     DO MyForm.wfm with "whatever"
>
> If you omit the parameter or start the form by clicking on it in the
> Navigator the form will start with records in natural order if no index
> has been set in the form at design time or in the order of the indexName
> coded in the form.
>
>
> If you need to pass more than one parameter, perhaps to change the
> heading on the form as well as the index or to open the form modally if
> required, add the additional parameters in your new bootstrap.  You will
> need to test to see if all the parameters have been passed and only
> apply those that are there.
>
>
> ****** Code to add in header section ****
> // Use actual names in place of MyFormForm and queryname
> parameter cIndexname
> local f
> f = new MyFormForm()
> if argCount() = 1
>      f.queryname.rowset.indexName = cIndexName
> endif
> f.open()
>
> RETURN // This return is important. If you leave it out
>          // the normal bootstrap will be executed
>
> ****** End of added code ********
> ** END HEADER -- do not remove this line
> //
> // Generated on 2016/07/18
> //
> parameter bModal
> local f
> f = new MyFormForm()
> if (bModal)
>      f.mdi = false // ensure not MDI
>      f.readModal()
> else
>      f.open()
> endif
>
> class MyFormForm of FORM
>    ........
>
> Mervyn.
>