Subject Re: indexing problem
From Mervyn Bick <invalid@invalid.invalid>
Date Tue, 19 Jul 2016 09:49:56 +0200
Newsgroups dbase.getting-started

On 18-Jul-16 11:07 PM, Charlie wrote:
> 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.
>

cIndex1 and cIndex2 are two variables in your XDML program.  Different
names because you have two different tags. :-)

In point of fact you don't even need to use variables. You could simply
hard-code the tag names as literal values.
       if nForm = 1
          DO myForm.wfm with "whatever"
       else
          DO myForm.wfm with "other"
       endif

It's a personal preference but I seldom use literal values directly in
code.  I usually assign the values to variables or user-defined
properties of an object.

The values after the WITH, be they literals or variables or even
properties such as form.entryfield1.value, are the "parameters" that are
passed to your OODML form.

At the form's end of the transaction  "parameter cIndexName" does two
things.  Firstly it tells the form that it can expect a parameter and
secondly it gives a variable in which the value passed to it is to be
stored.  As only one tag can be passed at a time I used cIndexName for
the variable name as this helps me remember what is in it.  It also is
meaningful to me as I am going to assign it to the indexName property of
the form's rowset. parameter x and f.queryname.rowset.indexName = x
would have worked just as well.

You can name variables anything you like today.  Back when I started
programming (using a VERY basic BASIC on an ICL mainframe computer) all
that was allowed were the single letters a to j.  One needed to add
copious remarks detailing what was in each variable so as not to get
things mixed up in the code.

I still use single letters, usually n or i, for counting loops but for
the rest I've adopted the convention of starting variable names with a
lowercase letter that indicates the type of variable.  c for character,
n for numeric, d for date, b for boolean (logical), a for array and so
on.  The second letter is uppercase to improve readability.   Many
programmers use this convention as it helps to make code
"self-documenting" but it is just a convention.  You don't have to use
it if you don't want to.


The code for a form in OODML is a class definition based on one of the
base classes in dBASE.  It is not executable code on its own.  In other
words this is just a blueprint for a form.  As it stands it can do
nothing.  One can, however, use it to create as many identical forms as
one needs.

To display the form dBASE needs to be told to create a form object in
memory.  This object has an open() method (and a readmodal() method)
which it has inherited from the base class which will display the form
on the screen.

The form designer places this code, which is known as the bootstrap
code, in a form immediately before the class definition.

parameter bModal
local f
f = new MyFormForm()
if (bModal)
       f.mdi = false // ensure not MDI
       f.readModal()
else
       f.open()
endif

This is actual executable code which can be executed by the dBASE DO
command.  Without it you would have to load the class definition into
memory, use the NEW command to create an object from the class
definition and then open the form yourself every time you wanted to
display the form.  One can, of course, still do this.  The little
example form I posted the other day for launching a report to be saved
as an HTML page in a file with the date as the name does exactly this.

Mervyn.