Maptitude GISDK Help |
The following syntax is used to read the value of a field in a view:
x = view_name.field_name
This syntax reads the value of field_name for the current record in view_name. If there is no current record, execution of this statement causes an error.
Here is a short sample macro that loops over each state in a dBASE file, reading the name and population of each one and displaying it in a message box:
// First, create the view
view = OpenTable("State Data", "DBASE", {"c:\\dbf\\states.dbf",} )
// Create a view|set for reading all records
view_set = view + "|"
rec = GetFirstRecord(view_set, null)
while rec <> null do
// read the state name and population
name = view.Name
pop = view.Population
// Display the information
str = "The population of " + name + " is " + String(pop)
ShowMessage(str)
// Go on to the next state
rec = GetNextRecord(view_set, null, null)
end
Note that the view_name must be a variable name and not a literal string. That is:
// This won't work...
name = States.Name
// Neither will this...
name = "States".Name
// This, on the other hand, works just fine...
vw = "States"
name = vw.Name
If the name of the field you want to read is stored in a variable, you must put parentheses around the variable, as follows:
// Here are two ways to read the state name...
vw = "States"
fld = "Name"
// These two statements do the same thing...
name = vw.Name
name = vw.(fld)
// I am going to read the values of three fields...
fld_names = {"Name", "Population", "Income"}
vw = "States"
// Read the three field values...
name = vw.(fld_names[1])
pop = vw.(fld_names[2])
inc = vw.(fld_names[3])
In addition to the above syntax, the following GISDK functions can be used to read data from a view:
GISDK Function |
Summary |
Reads a two-dimensional array of values from an editor window |
|
Reads the values of one or more fields in any number of views |
|
Reads the values of one or more fields for a record in a view |
|
Reads the values of one or more fields for a group of records in a view |
|
Samples the values of the specified field and returns the specified number of unique values |
©2025 Caliper Corporation | www.caliper.com |