Subject Re: Forms Processing Text Box buffer to Data Fields
From Robert Hughes <Hughes@infoconn.com>
Date Fri, 12 Sep 2014 19:44:08 -0400
Newsgroups dbase.getting-started

Mervyn,

Thank you so much for the response. I am starting to dig in a bit. The code examples are starting to make sense. You are very perceptive. I think in a procedural context. OPP is foreign to me. I started programming in the 1970's. Thanks for the code. One quick question. Is there a Date Entry Field formatting event handling section in the Forms Processor, ie. Key field kicked to uppercase. In dBase II I think the GET WAS formatted with "!!!!!!!" for uppercase.

Thanks, I love dBase.
Robert Hughes


Mervyn Bick Wrote:

> On Thu, 11 Sep 2014 01:25:25 +0200, Robert Hughes <hughes@infoconn.com>  
> wrote:
>
> > Hello, I have not coded anything since COBOL for Y2K. Can anyone point  
> > me to a sample File Maintenance Form that manages a sub-form  
> > Master/Detail relationship using the native .dbf file format. Is there  
> > any documentation concerning the Forms Processing definitions and  
> > Variables created by the Forms program generator.
>
> If you ask 12 programmers how to do this you'll probably get a dozen  
> different answers and each programmer will tell you that his/her method is  
> better than all the others. <g>
>
> The examples below have been tested with dBASE Plus 2.8 and dBASE Plus  
> 8.1.3.  They haven't been tested with dBASE Plus 9 but they should work.
>
> Mark and copy the code in masterrowset.wfm.  In the dBASE command panel  
> enter  modi comm masterrowset.wfm  and press enter.  This will open the  
> sourcecode editor.  Paste the code into the editor and save.  Follow the  
> same process with master_edit.wfm and child_edit.wfm.  You can then run  
> masterrowset.wfm.  The examples are written to recreate the tables every  
> time masterrowset.wfm is run.  To change this simply comment out each of  
> the two "drop table" commands at the top of masterrowset.wfm by placing //  
> at the start of each line
>
> dBASE is now focused on Object Oriented Programming (OOP) although most of  
> the old hierarchical commands that date back to CP/M and MSDOS based dBASE  
> are still available.  With OOP it is more common to use properties of  
> objects rather than variables although variables are available to the  
> programmer.
>
> The properties of all objects are listed in the Language Reference and the  
> dBASE help file.  In addition when a form is open in the form designer all  
> the properties, events and methods for the form and any objects on the  
> form can be seen in the Inspector.  If the Inspector isn't visible  
> pressing F11 should do the trick.
>
> You don't say what experience you have with OOP or which version of dBASE  
> you will be using.  Later versions of dBASE came with a complimentary copy  
> of the second issue of Ken Mayer's The dBASE Book.  (A copy of the third  
> edition would be a good investment.  Ken has also published the dBASE  
> Reports Book.  http://www.goldenstag.net/dbase/ )  You could also have a  
> look at the dBASE knowledgebase at  
> http://www.dbase.com/support/knowledgebase/
>
> Event driven programming for the Windows environment is a whole new ball  
> game compared to hierarchical programming so if you don't follow the code  
> in the examples please feel free to come back with questions.
>
>
> Mervyn.
>
>
> ******** Start of masterrowset.wfm ***************
> if file('mbcustomer.dbf')
>      drop table mbcustomer
> endif
>
> if not file('mbcustomer.dbf')
>     create table mbcustomer (custid autoinc,custname character(10),;
>       custcity character(15))
>
>    insert into mbcustomer (custname,custcity) values ("Alpha  
> ","Bloemfontein ")
>    insert into mbcustomer (custname,custcity) values ("Bravo ","Durban ")
>    insert into mbcustomer (custname,custcity) values ("Charlie ","Cape Town  
> ")
>    insert into mbcustomer (custname,custcity) values ("Delta  
> ","Johannesburg ")
>    insert into mbcustomer (custname,custcity) values ("Echo ","Brandfort ")
> endif
>
> if file('mbtrans.dbf')
>      drop table mbtrans
> endif
>
> if not file('mbtrans.dbf')
>     create table mbtrans (id autoinc,custid numeric(10,0),invno  
> character(10),invdate date,;
>       invamt numeric(10,2))
>
>    insert into mbtrans (custid,invno,invdate,invamt) values (1,"1001  
> ","01/31/2011",100.00)
>    insert into mbtrans (custid,invno,invdate,invamt) values (2,"1002  
> ","02/28/2011",200.00)
>    insert into mbtrans (custid,invno,invdate,invamt) values (3,"1003  
> ","03/31/2011",300.00)
>    insert into mbtrans (custid,invno,invdate,invamt) values (4,"1004  
> ","04/30/2010",400.00)
>    insert into mbtrans (custid,invno,invdate,invamt) values (1,"1005  
> ","05/31/2010",500.00)
>    insert into mbtrans (custid,invno,invdate,invamt) values (2,"1006  
> ","06/30/2010",110.00)
>    insert into mbtrans (custid,invno,invdate,invamt) values (3,"1007  
> ","07/31/2010",120.00)
>    insert into mbtrans (custid,invno,invdate,invamt) values (4,"1008  
> ","08/31/2010",130.00)
>    insert into mbtrans (custid,invno,invdate,invamt) values (1,"1009  
> ","09/30/2010",150.00)
>    insert into mbtrans (custid,invno,invdate,invamt) values (2,"1010  
> ","10/31/2010",150.00)
>    insert into mbtrans (custid,invno,invdate,invamt) values (3,"1011  
> ","11/30/2010",160.00)
>    insert into mbtrans (custid,invno,invdate,invamt) values (4,"1012  
> ","12/31/2010",170.00)
>    insert into mbtrans (custid,invno,invdate,invamt) values (4,"1013  
> ","12/31/2010",180.00)
>
>
>    use mbtrans exclusive
>    index on custId tag custid
>    use
>
> endif
>
> ** END HEADER -- do not remove this line
> //
> // Generated on 2014/09/11
> //
> parameter bModal
> local f
> f = new masterrowsetForm()
> if (bModal)
>     f.mdi = false // ensure not MDI
>     f.readModal()
> else
>     f.open()
> endif
>
> class masterrowsetForm of FORM
>     with (this)
>        onOpen = class::FORM_ONOPEN
>        onClose = class::FORM_ONCLOSE
>        height = 24.5455
>        left = 4.8571
>        top = 0.3636
>        width = 124.7143
>        text = ""
>     endwith
>
>     this.MBCUSTOMER1 = new QUERY()
>     this.MBCUSTOMER1.parent = this
>     with (this.MBCUSTOMER1)
>        left = 2.8571
>        top = 0.4091
>        sql = 'select * from "mbcustomer.DBF"'
>        active = true
>     endwith
>
>     with (this.MBCUSTOMER1.rowset)
>        autoEdit = false
>     endwith
>
>     this.MBTRANS1 = new QUERY()
>     this.MBTRANS1.parent = this
>     with (this.MBTRANS1)
>        left = 20.4286
>        top = 0.4091
>        sql = 'select * from mbtrans.dbf"'
>        active = true
>     endwith
>
>     with (this.MBTRANS1.rowset)
>        autoEdit = false
>        indexName = "CUSTID"
>        masterRowset = form.mbcustomer1.rowset
>        masterFields = "custid"
>     endwith
>
>     this.GRID1 = new GRID(this)
>     with (this.GRID1)
>        dataLink = form.mbcustomer1.rowset
>        allowEditing = false
>        allowAddRows = false
>        height = 7.7727
>        left = 5.0
>        top = 4.2273
>        width = 85.1429
>     endwith
>
>     this.GRID2 = new GRID(this)
>     with (this.GRID2)
>        dataLink = form.mbtrans1.rowset
>        allowEditing = false
>        allowAddRows = false
>        height = 7.7727
>        left = 5.0
>        top = 13.8182
>        width = 85.1429
>     endwith
>
>     this.TEXTLABEL1 = new TEXTLABEL(this)
>     with (this.TEXTLABEL1)
>        height = 1.0
>        left = 5.8571
>        top = 2.7273
>        width = 12.0
>        text = "Master"
>     endwith
>
>     this.TEXTLABEL2 = new TEXTLABEL(this)
>     with (this.TEXTLABEL2)
>        height = 1.0
>        left = 5.8571
>        top = 12.2727
>        width = 12.0
>        text = "Child"
>     endwith
>
>     this.PUSHBUTTON1 = new PUSHBUTTON(this)
>     with (this.PUSHBUTTON1)
>        onClick = class::PUSHBUTTON1_ONCLICK
>        height = 1.0909
>        left = 97.0
>        top = 7.5455
>        width = 15.2857
>        text = "Update Master"
>     endwith
>
>     this.PUSHBUTTON2 = new PUSHBUTTON(this)
>     with (this.PUSHBUTTON2)
>        onClick = class::PUSHBUTTON2_ONCLICK
>        height = 1.0909
>        left = 97.8571
>        top = 16.7273
>        width = 15.2857
>        text = "Update Child"
>     endwith
>
>     this.rowset = this.mbcustomer1.rowset
>
>     function PUSHBUTTON1_onClick
>        form.master_edit.mbcustomer1 = form.mbcustomer1
>        form.master_edit.entryfield1.datalink =  
> form.mbcustomer1.rowset.fields["custid"]
>        form.master_edit.entryfield2.datalink =  
> form.mbcustomer1.rowset.fields["custname"]
>        form.master_edit.entryfield3.datalink =  
> form.mbcustomer1.rowset.fields["custcity"]
>        form.master_edit.readmodal()
>        return
>
>     function PUSHBUTTON2_onClick
>        form.child_edit.mbcustomer1 = form.mbcustomer1
>        form.child_edit.entryfield1.datalink =  
> form.mbtrans1.rowset.fields["id"]
>        form.child_edit.entryfield2.datalink =  
> form.mbtrans1.rowset.fields["custid"]
>        form.child_edit.entryfield3.datalink =  
> form.mbtrans1.rowset.fields["invno"]
>        form.child_edit.entryfield4.datalink =  
> form.mbtrans1.rowset.fields["invdate"]
>        form.child_edit.entryfield5.datalink =  
> form.mbtrans1.rowset.fields["invamt"]
>        form.child_edit.readmodal()
>        return
>
>     function form_onClose
>        form.mbcustomer1.active = false
>        form.mbtrans1.active = false
>        return
>
>     function form_onOpen
>        set procedure to master_edit.wfm
>        form.master_edit = new master_editform()
>        form.master_edit.mdi = false
>        form.master_edit.parent = this
>        set procedure to child_edit.wfm
>        form.child_edit = new child_editform()
>        form.child_edit.mdi = false
>        form.child_edit.parent = this
>        return
>
> endclass
> *********** End of masterrroset.wfm ************
>
> ******** Start of master_edit.wfm *************
> ** END HEADER -- do not remove this line
> //
> // Generated on 2014/09/11
> //
> parameter bModal
> local f
> f = new master_editForm()
> if (bModal)
>     f.mdi = false // ensure not MDI
>     f.readModal()
> else
>     f.open()
> endif
>
> class master_editForm of FORM
>     with (this)
>        height = 16.0
>        left = 54.4286
>        top = 7.9091
>        width = 74.1429
>        text = "Update master table"
>        sysMenu = false
>     endwith
>
>     this.PUSHBUTTON1 = new PUSHBUTTON(this)
>     with (this.PUSHBUTTON1)
>        onClick = class::PUSHBUTTON1_ONCLICK
>        height = 1.0909
>        left = 2.4286
>        top = 12.1364
>        width = 15.2857
>        text = "New"
>     endwith
>
>     this.PUSHBUTTON2 = new PUSHBUTTON(this)
>     with (this.PUSHBUTTON2)
>        onClick = class::PUSHBUTTON2_ONCLICK
>        height = 1.0909
>        left = 2.8571
>        top = 10.5
>        width = 15.2857
>        text = "Edit"
>     endwith
>
>     this.PUSHBUTTON3 = new PUSHBUTTON(this)
>     with (this.PUSHBUTTON3)
>        onClick = class::PUSHBUTTON3_ONCLICK
>        height = 1.0909
>        left = 51.8571
>        top = 10.5
>        width = 15.2857
>        text = "Save"
>     endwith
>
>     this.PUSHBUTTON4 = new PUSHBUTTON(this)
>     with (this.PUSHBUTTON4)
>        onClick = class::PUSHBUTTON4_ONCLICK
>        height = 1.0909
>        left = 51.8571
>        top = 12.1364
>        width = 15.2857
>        text = "Abandon/Close"
>     endwith
>
>     this.ENTRYFIELD1 = new ENTRYFIELD(this)
>     with (this.ENTRYFIELD1)
>        onOpen = class::ENTRYFIELD1_ONOPEN
>        when = {||false}
>        height = 1.0
>        left = 8.1429
>        top = 6.4545
>        width = 8.0
>        value = ""
>     endwith
>
>     this.ENTRYFIELD2 = new ENTRYFIELD(this)
>     with (this.ENTRYFIELD2)
>        onOpen = class::ENTRYFIELD2_ONOPEN
>        height = 1.0
>        left = 21.5714
>        top = 6.5
>        width = 16.2857
>        value = ""
>     endwith
>
>     this.ENTRYFIELD3 = new ENTRYFIELD(this)
>     with (this.ENTRYFIELD3)
>        onOpen = class::ENTRYFIELD3_ONOPEN
>        height = 1.0
>        left = 43.2857
>        top = 6.5
>        width = 20.0
>        value = ""
>     endwith
>
>     this.TEXTLABEL1 = new TEXTLABEL(this)
>     with (this.TEXTLABEL1)
>        height = 1.0
>        left = 8.1429
>        top = 4.5909
>        width = 12.0
>        text = "custid"
>     endwith
>
>     this.TEXTLABEL2 = new TEXTLABEL(this)
>     with (this.TEXTLABEL2)
>        height = 1.0
>        left = 21.5714
>        top = 4.5909
>        width = 12.0
>        text = "custname"
>     endwith
>
>     this.TEXTLABEL3 = new TEXTLABEL(this)
>     with (this.TEXTLABEL3)
>        height = 1.0
>        left = 43.2857
>        top = 4.5909
>        width = 12.0
>        text = "custcity"
>     endwith
>
>     this.PUSHBUTTON5 = new PUSHBUTTON(this)
>     with (this.PUSHBUTTON5)
>        onClick = class::PUSHBUTTON5_ONCLICK
>        height = 1.0909
>        left = 27.2857
>        top = 10.5
>        width = 15.2857
>        text = "Delete"
>     endwith
>
>     function PUSHBUTTON1_onClick
>        form.entryfield1.datalink = null
>        form.entryfield1.value = "AutoInc"
>        form.parent.mbcustomer1.rowset.beginAppend()
>        form.entryfield2.setfocus()
>        return
>
>     function PUSHBUTTON2_onClick
>        form.parent.mbcustomer1.rowset.beginEdit()
>        return
>
>     function PUSHBUTTON3_onClick
>        form.parent.mbcustomer1.rowset.save()
>        form.close()
>        return
>
>     function PUSHBUTTON4_onClick
>        form.parent.mbcustomer1.rowset.abandon()
>        form.close()
>        return
>
>     function PUSHBUTTON5_onClick
>       local cMessage
>       cMessage = "Are you sure you want to delete this  
> record?"+chr(13)+chr(10)
>       cMessage += "All its child records will be deleted as well."
>       if msgbox( cMessage, "Delete", 4) == 6
>          form.parent.mbtrans1.rowset.first()
>          do while not form.parent.mbtrans1.rowset.endofset
>             form.parent.mbtrans1.rowset.delete()
>             form.parent.mbtrans1.rowset.next()
>          enddo
>          form.mbcustomer1.rowset.delete()
>          form.close()
>        endif
>        return
>
> endclass
> *********** End of master_edit.wfm ***************
>
> ***********child_edit.wfm ******************
> ** END HEADER -- do not remove this line
> //
> // Generated on 2014/09/11
> //
> parameter bModal
> local f
> f = new child_editForm()
> if (bModal)
>     f.mdi = false // ensure not MDI
>     f.readModal()
> else
>     f.open()
> endif
>
> class child_editForm of FORM
>     with (this)
>        height = 16.0
>        left = 54.4286
>        top = 7.9091
>        width = 74.1429
>        text = "Update master table"
>        sysMenu = false
>     endwith
>
>     this.PUSHBUTTON1 = new PUSHBUTTON(this)
>     with (this.PUSHBUTTON1)
>        onClick = class::PUSHBUTTON1_ONCLICK
>        height = 1.0909
>        left = 2.4286
>        top = 12.1364
>        width = 15.2857
>        text = "New"
>     endwith
>
>     this.PUSHBUTTON2 = new PUSHBUTTON(this)
>     with (this.PUSHBUTTON2)
>        onClick = class::PUSHBUTTON2_ONCLICK
>        height = 1.0909
>        left = 2.8571
>        top = 10.5
>        width = 15.2857
>        text = "Edit"
>     endwith
>
>     this.PUSHBUTTON3 = new PUSHBUTTON(this)
>     with (this.PUSHBUTTON3)
>        onClick = class::PUSHBUTTON3_ONCLICK
>        height = 1.0909
>        left = 51.8571
>        top = 10.5
>        width = 15.2857
>        text = "Save"
>     endwith
>
>     this.PUSHBUTTON4 = new PUSHBUTTON(this)
>     with (this.PUSHBUTTON4)
>        onClick = class::PUSHBUTTON4_ONCLICK
>        height = 1.0909
>        left = 51.8571
>        top = 12.1364
>        width = 15.2857
>        text = "Abandon/Close"
>     endwith
>
>     this.ENTRYFIELD1 = new ENTRYFIELD(this)
>     with (this.ENTRYFIELD1)
>        when = {||false}
>        height = 1.0
>        left = 7.4286
>        top = 2.9545
>        width = 8.0
>        value = ""
>     endwith
>
>     this.ENTRYFIELD2 = new ENTRYFIELD(this)
>     with (this.ENTRYFIELD2)
>        when = {||false}
>        height = 1.0
>        left = 20.8571
>        top = 3.0
>        width = 8.0
>        value = ""
>     endwith
>
>     this.ENTRYFIELD3 = new ENTRYFIELD(this)
>     with (this.ENTRYFIELD3)
>        height = 1.0
>        left = 6.2857
>        top = 6.6818
>        width = 17.4286
>        value = ""
>     endwith
>
>     this.TEXTLABEL1 = new TEXTLABEL(this)
>     with (this.TEXTLABEL1)
>        height = 1.0
>        left = 7.4286
>        top = 1.0909
>        width = 12.0
>        text = "id"
>     endwith
>
>     this.TEXTLABEL2 = new TEXTLABEL(this)
>     with (this.TEXTLABEL2)
>        height = 1.0
>        left = 20.8571
>        top = 1.0909
>        width = 12.0
>        text = "custid"
>     endwith
>
>     this.TEXTLABEL3 = new TEXTLABEL(this)
>     with (this.TEXTLABEL3)
>        height = 1.0
>        left = 6.2857
>        top = 5.1818
>        width = 12.0
>        text = "invno"
>     endwith
>
>     this.PUSHBUTTON5 = new PUSHBUTTON(this)
>     with (this.PUSHBUTTON5)
>        onClick = class::PUSHBUTTON5_ONCLICK
>        height = 1.0909
>        left = 27.2857
>        top = 10.5
>        width = 15.2857
>        text = "Delete"
>     endwith
>
>     this.ENTRYFIELD4 = new ENTRYFIELD(this)
>     with (this.ENTRYFIELD4)
>        height = 1.0
>        left = 27.4286
>        top = 6.7273
>        width = 17.4286
>        value = " "
>     endwith
>
>     this.ENTRYFIELD5 = new ENTRYFIELD(this)
>     with (this.ENTRYFIELD5)
>        height = 1.0
>        left = 48.5714
>        top = 6.6818
>        width = 17.4286
>        value = " "
>     endwith
>
>     this.TEXTLABEL4 = new TEXTLABEL(this)
>     with (this.TEXTLABEL4)
>        height = 1.0
>        left = 27.4286
>        top = 5.1818
>        width = 12.0
>        text = "invdate"
>     endwith
>
>     this.TEXTLABEL5 = new TEXTLABEL(this)
>     with (this.TEXTLABEL5)
>        height = 1.0
>        left = 48.5714
>        top = 5.0455
>        width = 12.0
>        text = "invdate"
>     endwith
>
>
>     function PUSHBUTTON1_onClick
>        form.entryfield1.datalink = null
>        form.entryfield1.value = "AutoInc"
>        form.parent.mbtrans1.rowset.beginAppend()
>        form.entryfield3.setfocus()
>        return
>
>     function PUSHBUTTON2_onClick
>        form.parent.mbtrans1.rowset.beginEdit()
>        return
>
>     function PUSHBUTTON3_onClick
>        form.parent.mbtrans1.rowset.save()
>        form.close()
>        return
>
>     function PUSHBUTTON4_onClick
>        form.parent.mbtrans1.rowset.abandon()
>        form.close()
>        return
>
>     function PUSHBUTTON5_onClick
>        if msgbox( "Are you sure you want to delete this record?", "Delete",  
> 4) == 6
>           form.parent.mbtrans1.rowset.delete()
>           form.close()
>        endif
>        return
>
> endclass
> *********** End of child_edit.wfm ***********