replace_field_values.sml

  Download

More scripts: Vector

Syntax Highlighing:

comments, key words, predefined symbols, class members & methods, functions & classes
            
# Searches the specified Table.Field for a specified value
# replaces that value with a different given value
#
vector V;
PopupMessage("Select /litedata/sf_data/HAYWSOIL/hsoils");
GetInputVector(V);
 
numeric numRecords = NumRecords(V.poly.Wildlife);     # apparently table name isn't replaceable
 
string oldName$ = "Fair";    # field value that will be replaced
string newName$ = "NewFieldName";    # field value to replace it
string fieldName$ = "Grasses_Legumes";    # variable field name
 
numeric i;
for i = 1 to numRecords  # loop through records
{
    if(V.poly.Wildlife[@i].(fieldName$)$ == oldName$) # if fieldValue found
    {
        V.poly.Wildlife[@i].(fieldName$)$ = newName$; # store new Value
    }
}