Maptitude GISDK Help

Reading and Writing from Several Views

The syntax for reading and writing values to a view allows you to manipulate several views or tables at once, reading and writing as necessary. Maptitude keeps track of the current record for all open views, so changing the current record in one view does not affect the current record in another view.

 

Here is a sample macro that works on two views: Customers and SalesReps. The macro loops over sales reps, finds the customers that go with each one, computes the total sales for each sales rep, and stores the result in the sales rep view.

 

// First, create the two views

reps = OpenTable("Sales Reps", "DBASE", "c:\\dbf\\salesrep.dbf", )

custs = OpenTable("Customers", "DBASE", "c:\\dbf\\customer.dbf", )

SetView(custs)          // for the SelectByQuery() function, which appears below

 

// Start looping over the sales reps

rep_rec = GetFirstRecord(reps + "|", null)

while rep_rec <> null do

 

     // Read the rep ID

     rep_id = reps.ID

 

     // Select the customers for this rep

     sql = "Select * where REP_ID = " + String(rep_id)

     n = SelectByQuery("Selection", "Several", sql)

     total_sales = 0.0

 

     cust_rec = GetFirstRecord(custs + "|Selection", null)

     while cust_rec <> null do

          // Read the sales volume for this customer

          total_sales = total_sales + custs.Sales

          cust_rec = GetNextRecord(custs + "|Selection", null, null)

          end

 

     // Now write out the total sales

     reps.Sales = total_sales

 

     // Go on to the next rep...

     rep_rec = GetNextRecord(reps + "|", null, null)

     end

 

 

©2025 Caliper Corporation www.caliper.com