Problem
An existing enumeration value should be renamed or replaced
Approach – Ansatz
We have to iterate through the Type-Array and repopulate new arrays, which will be used as parameters for the modify function
Solution – Lösung
//This program was intended to replace the values of an enumerated attribute
//The replace will not affect the current selected values, it will just change the value to the new one
pragma runLim, 0
void replaceAttributeTypeValue(Module m, string atName, string oldVal, string newVal){
AttrType att = find(m, atName)
//Declare Arrays Size
int colores[att.size]
int arrMap[att.size]
string arr[att.size]
int arrVal[att.size]
int i
//Populate Arrays
for(i = 0; i < att.size; i++){
arr[i] = att.strings[i]
arrVal[i] = i
colores[i] = -1
arrMap[i] = i
}
//
for(i = 0; i < sizeof(arr); i++){
if(arr[i] == oldVal){
arr[i] = newVal
}
}
string err = null
AttrType at2 = modify(att, atName, arr, arrVal, colores, arrMap, err)
if(!null err){
print "Failed: " err"\n"
}
else{
infoBox at2.name " - Modified Successfully"
}
}