Enumerate attributes + their possible types

hey guys,

I would like to write a script that exports all attributes within the current module + their possible types, such as String, Text and if it's an enum, all possible enumeration types.
I know how to get all attributes within the current module and how to export them to excel, but I have no clue how to get the type and especially how to get all possible values if it's an enum type.

I'd be grateful for help.

All the best,

Yannick
YaMo - Wed Aug 24 07:52:00 EDT 2011

Re: Enumerate attributes + their possible types
mcnairk - Wed Aug 24 08:12:42 EDT 2011

Something like the following?

Ken.
 

Module m = current;
print name(m)"\n";
print "Type Name\tBase Type\tValues\n";
AttrType at;
for at in current Module do {
int i;
print (at.name)"\t"(at.type)"";
if (at.type"" == "Enumeration") {
for ( i = 0; i < at.size; i++){
print "\t"at.strings[i];
}
}
print "\n"
}

Re: Enumerate attributes + their possible types
YaMo - Wed Aug 24 08:23:43 EDT 2011

mcnairk - Wed Aug 24 08:12:42 EDT 2011

Something like the following?

Ken.
 

Module m = current;
print name(m)"\n";
print "Type Name\tBase Type\tValues\n";
AttrType at;
for at in current Module do {
int i;
print (at.name)"\t"(at.type)"";
if (at.type"" == "Enumeration") {
for ( i = 0; i < at.size; i++){
print "\t"at.strings[i];
}
}
print "\n"
}

Thank you so much!! This is exactly what I needed.. looks so simple but it would have taken me a long time to figure out by myself.

Cheers,

Yannick

Re: Enumerate attributes + their possible types
llandale - Thu Aug 25 10:24:29 EDT 2011

mcnairk - Wed Aug 24 08:12:42 EDT 2011

Something like the following?

Ken.
 

Module m = current;
print name(m)"\n";
print "Type Name\tBase Type\tValues\n";
AttrType at;
for at in current Module do {
int i;
print (at.name)"\t"(at.type)"";
if (at.type"" == "Enumeration") {
for ( i = 0; i < at.size; i++){
print "\t"at.strings[i];
}
}
print "\n"
}

Perhaps a 2nd report of Attribute Definitions.

Module m = current;
print name(m)"\n";
print "Name\tType\tBaseType\n";
AttrDef ad;
AttrType at
for ad in m do {
   at = ad.type
   print (at.name)"\t" (ad.typeName) "\t" (at.type) "\n"
}


Users can see an Enumeration in this report, then go to your report to get all its enumerated values. You could put that info in this report but then you'd repeat the Enumerations if that type is used by more than one Definition.

The "Base Type" may be interesting; perhaps you have type defined "Percent" and need to know is basically an "Integer" rather than an "Enumeration" or "Real".

 

 

  • Louie


If you look at the results we see that a "Boolean" type is just an "Enumerated" with values "True" and "False"; and its cleverly translated to "true" and "false" when set to a boolean attribute.