IDLffShape::AddAttribute

The IDLffShape::AddAttribute method adds an attribute definition to a Shapefile. Adding the attribute definition is required before adding the actual attribute data to a file. For more information on attributes, see Attributes.

Note: You can only define new attributes to Shapefiles that do not have any existing values in any attributes.

Syntax

Obj->[IDLffShape::]AddAttribute, Name, Type, Width [, PRECISION=integer]

Arguments

Name

Set to a string that contains the attribute name. Name values are limited to 10 characters. Names longer than 10 characters will be truncated.

Type

Set to the IDL type code that corresponds to the data type that will be stored in the attribute. The valid types are:

Code

Type

3

Longword Integer

5

Double-precision

floating point

7

String

Width

Set to the user-defined width of the field for the data value of the attribute. The following table describes the possible values depending on the defined Type:

Longword Integer

Establishes the number of digits of the largest number that can be represented. Numbers that are larger than this value will be truncated.

 

Double-precision

floating point

Establishes the total number of digits, including the decimal point and the number of positions after the decimal point (see the PRECISION keyword). Numbers that cannot be represented with this width will be truncated.

 

String

Establishes the maximum length of the string that can be stored. Strings longer than this length will be truncated.

Note: You should ensure that the Width and PRECISION are large enough to store your largest value. Attributes that are larger than the width will be quietly truncated in the resulting file, and could result in loss of data or incorrect results.

Keywords

PRECISION

Set this keyword to the number of positions to be included after the decimal point. The default is 8. This keyword is only valid for fields defined as double-precision floating-point.

Examples

For an example of AddAttribute, see Creating New Shapefiles.

Note: If cities.shp already contains data in an attribute for any of the entities defined in the file, this operation will fail.

Version History

5.4

Introduced