VECSetField

Demonstrates how to set attribute field on a shape in a vector layer.

Remarks

This example illustrates how to clear all fields for a shape.

Code

 local integer tfid, integer layer, integer i
 local string temp_file
 local string field_type
 local int shape

 try
    temp_file = "./my.pix"
    delete temp_file noerror
    call CopyFile( GetPCIHOME() + "/demo/irvine.pix", \
                 temp_file)

    tfid = DBOpen(temp_file, "r+")
    layer = 31
    shape = 2
    for i = 1 to VECGetFieldCount(tfid,layer)
        field_type = VECGetFieldType(tfid,layer,i)
        if( field_type = "String" )then
             call VECSetField(tfid,layer,shape,i,"")
        else 
             call VECSetField(tfid,layer,shape,i,0.0)
        endif
    endfor

    for i = 1 to VECGetFieldCount( tfid, layer)
        field_type = VECGetFieldType(tfid, layer, i)
        if field_type = "String" Then
             print  "Field no.: ", i 
             print "Type: String" 
             print "Value: "+ VECGetField(tfid, layer, shape, i)
        else 
             if field_type = "CountedInt" then
                print  "Field no.: ", i 
                print "Type: " + field_type

                local  integer j
                local integer ptr intarray

                intarray = VECGetField(tfid, layer, shape, i)
                print " Start:"
                print " No. Items = ", F$len(intarray)
                for j = 1 To F$len(intarray)
                   print " ", j, " = ", intarray(j)
                endfor
                print " End:"
             else
                 print  "Field no.: ", i 
                 print "Type: " + field_type
                 print "Value: ", VECGetField(tfid, layer, shape, i)
             endif
        endif
    endfor
    call DBClose(tfid)
 onerror
   print "Error: "+ GetLastErrorMessage()
 endonerror

© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.