Subject Re: SQL or Array Rowset ?
From Akshat Kapoor <akshat.kapoor@kapoorsons.in>
Date Tue, 6 Apr 2021 22:27:23 +0530
Newsgroups dbase.getting-started
Attachment(s) test_array.wfmtest_array.prg

Good Evening Ronnie,


> Many thanks for your response
> I will certainly give that a try.
> Would much rather do the processing up front and then display it.
> Should be able to drop the inventory status table currently being
> displayed....
>
> This is new and unchartered territory - fun !

You take a look at the examples in help file. Do some testing in
standalone forms

And then it will be just like any other rowset.

I have attached some sample programs that I had built using examples
from help file.

data has to be copied from file to array.

Declare column names in another array

And then load the data into the arrayrowset.

Change values as desired (Inventory value in this case)

Display the data

Regards
Akshat



** END HEADER -- do not remove this line
//
// Generated on 23.11.2020
//
parameter bModal
local f
f = new test_arrayForm()
if (bModal)
   f.mdi = false // ensure not MDI
   f.readModal()
else
   f.open()
endif

class test_arrayForm of FORM
   with (this)
      onOpen = class::FORM_ONOPEN
      onDesignOpen = class::FORM_ONDESIGNOPEN
      doubleBuffered = true
      height = 26.4091
      left = 27.7143
      top = 0.0
      width = 168.7143
      text = ""
   endwith

   this.GRID1 = new GRID(this)
   with (this.GRID1)
      anchor = 1        // Bottom
      height = 13.5
      left = 0.0
      top = 12.8182
      width = 168.4286
   endwith

   this.TEXT1 = new TEXT(this)
   with (this.TEXT1)
      height = 1.0
      left = 54.0
      top = 7.0
      width = 12.0
      text = "Text1"
   endwith


   function form_onDesignOpen(bFromPalette)
//                use :dbasesamples:customers.dbf
//                a = new array(reccount(), fldcount())
//                copy to array a all
//                use    // close customers.dbf
//                ?a[1,2],a[2,2]
//                // setup 1 dimensional array with column names
//                acol = new array(10)
//                acol[1] = "CustomerID"
//                acol[2] = "Company"
//                acol[3] = "LastName"
//                acol[4] = "FirstName"
//                acol[5] = "Phone"
//                acol[6] = "Address1"
//                acol[7] = "Address2"
//                acol[8] = "City"
//                acol[9] = "State"
//                acol[10] = "Zip"
//                // Create arrayRowset object and load it
//                form.r = new arrayrowset()   // create arrayrowset r
//                form.r.load(a, acol)      
//      form.grid1.datalink = form.r
      return

   function form_onOpen()
                use :dbasesamples:customers.dbf
                a = new array(reccount(), fldcount())
                copy to array a all
                use    // close customers.dbf
                ?a[1,2],a[2,2]
                // setup 1 dimensional array with column names
                acol = new array(10)
                acol[1] = "CustomerID"
                acol[2] = "Company"
                acol[3] = "LastName"
                acol[4] = "FirstName"
                acol[5] = "Phone"
                acol[6] = "Address1"
                acol[7] = "Address2"
                acol[8] = "City"
                acol[9] = "State"
                acol[10] = "Zip"
                // Create arrayRowset object and load it
                form.r = new arrayrowset()   // create arrayrowset r
                form.r.load(a, acol)
      form.grid1.datalink = form.r
                ?form.r.fields["Company"].value
                form.r.next()
                ?form.r.fields["Company"].value
                form.grid1.refresh()
      return

endclass



                use :dbasesamples:customers.dbf
                a = new array(reccount(), fldcount())
                copy to array a all
                use    // close customers.dbf
                ?a[1,2],a[2,2]
                // setup 1 dimensional array with column names
                acol = new array(10)
                acol[1] = "CustomerID"
                acol[2] = "Company"
                acol[3] = "LastName"
                acol[4] = "FirstName"
                acol[5] = "Phone"
                acol[6] = "Address1"
                acol[7] = "Address2"
                acol[8] = "City"
                acol[9] = "State"
                acol[10] = "Zip"
                // Create arrayRowset object and load it
                public r
                r = new arrayrowset()   // create arrayrowset r
                r.load(a, acol)
                a= r.count()
                ?a
                for b = 2 to a
                        r.first()
                        r.delete()
                endfor
                ?r.count()