Subject Re: ALIAS
From Mustansir A Ghor <mustan31@hotmail.com>
Date Sun, 14 May 2017 12:51:56 -0400
Newsgroups dbase.getting-started

Dear Mervyn

It was good to know from below program that objects can also be equated.
if form.grid1.datalink = form.country1.rowset

also i Would like to know if following syntax can be correct and what it implies if "class" is omitted in the pushbutton property

onClick = PUSHBUTTON1_ONCLICK()

Best Regards
Mustansir



Mervyn Bick Wrote:

> On 2017-05-14 4:56 AM, AGOSTINHO wrote:
> > AGOSTINHO Wrote:
> >
> > My question is at "function PUSHBUTTON1_onClick()" how do I use ALIAS to switch from database?
> >
> >  this.PRODUCTS1 = new QUERY(this)
> >    with (this.PRODUCTS1)
> >       left = 6.0
> >       top = 1.0
> >       sql = 'select * from "C:\PRODUCTS.DBF"'
> >       active = true
> >    endwith
> >
> >    this.COUNTRY1 = new QUERY(this)
> >    with (this.COUNTRY1)
> >       left = 21.0
> >       top = 1.0
> >       sql = 'select * from "C:\dBASEtutorial\country.DBF"'
> >       active = true
> >    endwith
> >
> > function PUSHBUTTON1_onClick()
> >       SKIP
> >       return
> >
>
> In your first message you asked how to switch from one SQL data base to
> another using the alias command.  The code in this message shows you are
> using .dbf files and not a SQL server.
>
> SKIP is a command that comes from the older DOS based versions of dBASE.
>   These older commands are commonly referred to as XDML.  It is still
> available in the newer versions of dBASE but it is not used with the new
> object based code.  The newer object based commands are called OODML
>
> In the older versions of dBASE an ALIAS was a name given to a rowset
> open in a workarea.  OODML has SOURCECODE ALIAS and DATABASE ALIAS.
> neither of which is exactly the same as the old ALIAS.  A DATABASE ALIAS
> requires the use of a database object for each database and this is
> covered in the tutorial.
>
> In the attached example I have used two DATABASE ALIASes namely
> DBASESAMPLES which is created when you install dBASE and DBASETUTORIAL
> which you would have created as you work through the tutorial.  You
> would use the same code if you wanted tables from two different SQL
> databases.
>
> It is better programming practice to use a database alias and a database
> object as I have done whether you are using SQL tables or .dbf tables.
> If you are using .dbf files you can use query objects with the full path
> to the .dbf table as you have done in which case you don't need the
> database objects.  This is, however, not good practice.
>
> With or without database objects the code to switch between tables is
> the same.  Set the grid's dataLink property to the required rowset.
>
> If I have not understood your problem correctly please try and give a
> bit more detail on what you want to do.
>
> Mervyn.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ** END HEADER -- do not remove this line
> //
> // Generated on 2017-05-14
> //
> parameter bModal
> local f
> f = new test_change_tableForm()
> if (bModal)
>    f.mdi = false // ensure not MDI
>    f.readModal()
> else
>    f.open()
> endif
>
> class test_change_tableForm of FORM
>    with (this)
>       height = 25.3182
>       left = 33.4286
>       top = 7.8182
>       width = 66.5714
>       text = ""
>    endwith
>
>    this.DBASETUTORIAL1 = new DATABASE(this)
>    with (this.DBASETUTORIAL1)
>       left = 9.0
>       width = 11.0
>       height = 1.0
>       databaseName = "DBASETUTORIAL"
>       active = true
>    endwith
>
>    this.DBASESAMPLES1 = new DATABASE(this)
>    with (this.DBASESAMPLES1)
>       left = 20.0
>       width = 11.0
>       height = 1.0
>       databaseName = "DBASESAMPLES"
>       active = true
>    endwith
>
>    this.CUSTOMERS1 = new QUERY(this)
>    with (this.CUSTOMERS1)
>       left = 31.0
>       width = 9.0
>       height = 1.0
>       database = form.dbasesamples1
>       sql = "select * from CUSTOMERS.DBF"
>       active = true
>    endwith
>
>    this.COUNTRY1 = new QUERY(this)
>    with (this.COUNTRY1)
>       left = 3.0
>       width = 8.0
>       height = 1.0
>       database = form.dbasetutorial1
>       sql = "select * from COUNTRY.DBF"
>       active = true
>    endwith
>
>    this.PUSHBUTTON1 = new PUSHBUTTON(this)
>    with (this.PUSHBUTTON1)
>       onClick = class::PUSHBUTTON1_ONCLICK
>       height = 1.0909
>       left = 25.4286
>       top = 22.0
>       width = 15.2857
>       text = "Show other table"
>    endwith
>
>    this.GRID1 = new GRID(this)
>    with (this.GRID1)
>       dataLink = form.country1.rowset
>       height = 15.0
>       left = 8.5714
>       top = 4.0
>       width = 49.0
>    endwith
>
>    this.rowset = this.country1.rowset
>
>    function PUSHBUTTON1_onClick()
>       if form.grid1.datalink = form.country1.rowset
>          form.grid1.datalink = form.customers1.rowset
>       else
>          form.grid1.datalink = form.country1.rowset
>       endif
>       return
>
> endclass
>
>