The GetDynamicField() method will be used to access attributes fields in the current shape. If a field reference is performed that doesn't refer to an actual field in the class VLShape, then the GetDynamicField() function will be invoked automatically with the field name as its only argument. The function will use that argument to search the list of field names kept in memory to determine the corresponding field number. The field number can then be used to allow VECGetField() to access the field value.
define method GetDynamicField( field ) on VLShape
if ( this.fd = 0 ) then
call EASIError( 703, "No Currently opened file" )
endif
local integer fieldnum
fieldnum = FindSubString( this.fieldnames, field )
if ( fieldnum = -1 OR \
field != this.fieldnames[fieldnum] ) then
call EASIError( 701, "Field %s not found", field )
endif
return( VECGetField( this.fd, this.layer, this.shape, \
fieldnum ) )
enddefine
The SetDynamicField() method operates in an analogous manner to GetDynamicField(), except it receives an extra argument containing the value to which the given field should be set.
define method SetDynamicField( field, value ) on VLShape
if ( this.fd = 0 ) then
call EASIError( 703, "No Currently opened file" )
endif
if ( this.access <> "w" AND this.access <> "r+" ) then
call EASIError( 702, "Invalid access for operation" )
endif
local integer fieldnum
fieldnum = FindSubString( this.fieldnames, field )
if ( fieldnum = -1 OR \
f$len(field) != f$len(this.fieldnames[fieldnum]) ) then
call EASIError( 701, "Field %s not found", field )
endif
call VECSetField( this.fd, this.layer, this.shape, \
fieldnum, value )
enddefine
The dynamic field access methods make it particularly convenient if a script is written for vector layers with a known set of attribute names.
For example, the following script can be used to iterate over all the shapes in a layer, and print the attributes called "Attribute" and "Group" for each shape to the screen.
local VLShape shape call shape.open( "irvine.pix", 25 ) call shape.First() while ( shape.AtEnd != "TRUE" ) printf "Attribute: %s\n", shape.Attribute printf "Group: %s\n", shape.Group call shape.Next() endwhile call shape.Close()
© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.