Problem
An Attribute shall be deleted and replaced (recreated) by the same attribute with another type.
Approach
– Delete old attribute
– Create new one
– Views will not get lost with this method!
Solution
void deleteAttrDef(Module m, string s)
{
string err;
AttrDef ad = find(m, s);
err = delete(ad);
if (err !="") ack err;
}
void modifyAttributeType(Module m, string theAttribute, string newAttributType)
{
current = m;
// Delete Attribute attribute1 if exists
if (exists(attribute(string theAttribute)))
{
deleteAttrDef(m, theAttribute);
}
// Create new attribute1 of type TEXT (not string)
AttrDef ad = create object type newAttributType attribute theAttribute
if (null ad)
{
print "attr didn't create for module " fullName(m) "\n";
halt;
}
}
modifyAttributeType(current Module, "My_Attribut_To_Change_Type", "Text");