I'm writing a VBScript script to assist in laying out the architecture of some software I'm developing at work. I'm parsing the header files for defined enumerations, structs, function definitions, and some auto-generated commented stuff related to the categorical structure of our modules.
It's all going swimmingly, and I can create an appropriate package (we categorize our modules by layer level, i.e. drivers vs application level, etc), add a Component, then populate the Component with a blank Diagram, Enumerations for state and error, an Interface for methods, and a struct for the data structure.
My problem is coming in when I try to populate the Enumerations with Attributes. When I do it by hand, they're listed in the proper order (where they would resolve to 0, 1, etc.), but when I populate them while parsing the header file, they get entered alphabetically, which is obviously a problem.
I tried modifying the Default member of each Attribute with it's corresponding numerical value, but it still alphabetized them (and added the numerical value, too).
Here's a snippet of my code. Hopefully it's sufficient!
set newStateEnum = newComponent.Elements.AddNew(fileName & "_state_t", "Enumeration")
dim tempState, initialValue
dim tempAttribute as EA.Attribute
initialValue = 0
for each tempState in stateParts
if InStr(tempState, "=") > 0 then
set tempAttribute = newStateEnum.Attributes.AddNew(Split(tempState, "=")(0), "enum")
else
set tempAttribute = newStateEnum.Attributes.AddNew(Split(tempState, ",")(0), "enum")
end if
tempAttribute.Default = initialValue
initialValue = initialValue + 1
tempAttribute.Update()
next
newStateEnum.Update()