Subject Re: VARIABLE DECLARATION
From MUSTANSIR GHOR <mustan31@hotmail.com>
Date Mon, 16 Apr 2018 15:39:17 -0400
Newsgroups dbase.getting-started

Dear Mervyn

Thank you for detail reply. May God bless you. I hope you feeling well.

The between form and data objects are very clear. Thanks once again.

However I will keep on asking , I am sorry but you are our Doctor.

I have a set of radiobuttons. Each button selection needs to assigns a datasource property of a combobox to a table field NAME based of radio button selection. Although these tables (for each radio button) are different but their field structures are same.

The confusion is do i need to create for all 5 tables , 5 queries in the constructor code at begining of class and assign at radio but event appropiate rowset.fields["NAME"] to datasource of cbitem

OR

I create query here (of course I worder this query will not be associated with form) and assign it to datasource property of cbitem. Will this work because query created here will vanish at the of event.

The difference in both in my opinion is 1st one  takes up more memory than 2nd one.


Please can you guide on this

Best Regards
Mustansir

Mervyn Bick Wrote:

> On 2018-04-13 9:57 PM, Mustansir Ghor wrote:
>
> > Here as I understand readmodel() is similar to READ in DOS, where
> > execution stops waiting for user response. But rest all commands are
> > executed and load in memory. Based on mouse and keyboard action they
> > respond. Component order are based on Z order (if Tab is followed) but
> > any component can be executed independently (if enabled). This can be
> > for all wfm, rep, mnu objects.
>
> The difference between READ and readmodal() is that READ stops the
> program and waits for the user to enter a value or a set of values to be
> used later in the program.  readmodal() is normally used to launch a
> second form.  All processing in the main form stops while the second
> form is open and the user can't access the main form while the second
> form is open.
>
> The second form can be, say, a fully functional data entry and edit form
> where the user can add, delete or change as many records as necessary.
> The moment the second form is closed control returns to the main form.
>
> Unless the second form has explicitly passed values back to the main
> form it has no influence on the rest of the code in the main form.  If
> there are any commands after the readmodal() instruction in the function
> they are executed.
>
> If open() had been used to launch the second form the form would have
> opened and any instructions after the open() command would have been
> executed immediately.   The user could move freely from second form to
> main form and back again.  While the main form has focus any of its
> options can be executed even though the second form is still open.
>
> > Several times Ken Sir mentioned that data objects can be treated
> > differently as they can not be associated with form.  But we have
> > queries attached to a form. There are situations where form objects are
> > in the same commands with data objects. On otherhand we have SQL
> > statements can be executed independently within the form.
>
> It's not that data objects can't be associated with a form (they are but
> more on this later) but rather that they are treated differently.  (The
> same applies to timer objects.)  They are non-visible objects and they
> don't appear in the z-order.
>
> A data object is any object that handles data such as a query, a rowset,
> which "belongs" to a query object or a field which belongs to the fields
> object which belongs to a rowset.  For a full list have a look a "data
> model" in the help file.
>
> Any event handler triggered by a data object event doesn't understand
> 'form'. Instead of 'form' one needs to use this.parent......
>
> For instance the following function is an event handler triggered by the
> onNavigate event of the rowset.   a7 is a calculated field where the
> value is a percentage of the sum of a1 to a6.  Selecting a row in a grid
> triggers the event handler
>
> The event handler is used to display the value for a7 in a text object
> on the form and a text object on a container in a notebook
>
> Where one would normally use form.text1.text = 'whatever', in say, a
> pushbutton's onClick event handler one needs to use
> this.parent.parent.text1.text = 'whatever' because this is a data object
> event handler.
>
>     function rowset_onNavigate(type, nRows)
>        this.parent.parent.text1.text = this.fields['a7'].value
>        //this is the rowset.
>        //this.parent is the query.
>        //this.parent.parent is the form.
>        this.parent.parent.notebook1.container1.text1.text =
> this.fields['a7'].value
>        //Again, this.parent.parent is the form
>        return
>
>
> > One may ask What is the point. I am unable clearly understand how and
> > where data objects can be used correctly in a form. Just an example On
> > one event I have command form.mq1.rowset.findkey(form.cbitem.value). If
> > the record is found (event execution completed), and user clicks another
> > different event, will form.mq1.rowset record position remain to the same
> > record (assume it was not referred in the current event) as it stopped
> > at found position.
>
> Any time you need to access a table in a form you use a query object,
> which is a data object,
>
> When you drag a table onto a form in the designer dBASE streams out
> something like the following to create an instance of the query.
>
>     this.tableName1 = new QUERY(this)
>
>     In this.tableName1 "this" tells the query that it "belongs" to the
> form.  "This" in QUERY(this) tells the query that its parent is the form.
>
>     In earlier versions of dBASE assigning the query to the form and
> telling the query its parent is the form was done in two steps.
>
>     this.tableName1 = new QUERY()
>     this.tableName1.parent = this
>
> Here, the "this" on either side of the = is the form.
>
>
> Mervyn.
>