Hi, |
Re: Print all values of a multi enumeration Change "My_enum" to the type you want to print the values for
AttrType at = find (current Module, "My_enum")
int lll
for (lll = 0; lll < at.size; lll++) {
print "Value = " at.strings[lll] "\t"
print "Rel numb = " at.values[lll] "\t"
print "Color = " at.colors[lll] "\n"
}
|
Re: Print all values of a multi enumeration SystemAdmin - Tue Nov 24 07:20:05 EST 2009 Change "My_enum" to the type you want to print the values for
AttrType at = find (current Module, "My_enum")
int lll
for (lll = 0; lll < at.size; lll++) {
print "Value = " at.strings[lll] "\t"
print "Rel numb = " at.values[lll] "\t"
print "Color = " at.colors[lll] "\n"
}
but /offtopic is there a possibility to create a "temporary" attribute that is deleted when i close the module? Background: For some import in another system i need to "split" the multi valued attributes and an paste the values in seperated attributes and export these attributes to Excel. For example i have a multivalued attribute "TestMethod" with the values: "Inspection" "Analysis" "Demonstration" "Test". But in my target application i can only import "bitfields". So i need the Attributes TestMethod_Inspection (true/false) TestMethod_Anaylsis (true/false) TestMethod_Demonstration (true/false) TestMethod_Test (true/false) So what do you think about a script, that creates a temporary attribute for each value of an multivalued enum? thanks |
Re: Print all values of a multi enumeration haiderti - Tue Nov 24 10:35:24 EST 2009 Either a layoutDxl or attributeDxl might prove easier. |
Re: Print all values of a multi enumeration haiderti - Tue Nov 24 10:35:24 EST 2009
You should use DXL Layout Columns for this, since you can create them by script "on-the-fly" if neccessary, even if you module is opened for read. You will achieve the same results as with the temporary attributes (if your goal is to export them).
void createColumn (string whichValue) {
string pattern = "string val = obj.\"TestMethod\"; int d1,d2; "
pattern = pattern "if (findPlainText(val, \"" whichValue "\",d1,d2,true)) display \"true\" else display \"false\""
Column c = insert column 0
dxl (c, pattern)
title(c, "TextMethod_" whichValue)
}
string values[] = {"Inspection", "Analysis", "Demonstration", "Test"}
for i in 0:sizeof values -1 do createColumn values[i]
|
Re: Print all values of a multi enumeration Mathias Mamsch - Tue Nov 24 15:42:33 EST 2009
You should use DXL Layout Columns for this, since you can create them by script "on-the-fly" if neccessary, even if you module is opened for read. You will achieve the same results as with the temporary attributes (if your goal is to export them).
void createColumn (string whichValue) {
string pattern = "string val = obj.\"TestMethod\"; int d1,d2; "
pattern = pattern "if (findPlainText(val, \"" whichValue "\",d1,d2,true)) display \"true\" else display \"false\""
Column c = insert column 0
dxl (c, pattern)
title(c, "TextMethod_" whichValue)
}
string values[] = {"Inspection", "Analysis", "Demonstration", "Test"}
for i in 0:sizeof values -1 do createColumn values[i]
thanks a lot Mathias. That works fine :) Regards Tim |
Re: Print all values of a multi enumeration You need to get a handle on the AttrType from the AttrDef. Here's an existing function that counts, you can add sekrboe's code.
//********************
int fCountAD(Module mod, string NameAD, string &NameAT)
{ // Count the number of enumerated values of the Enumerated Attribute NameAD.
// Update the name of the associated Attribute Type.
// If its not Enumerated, return -1.
int Count = -1
AttrDef ad
AttrType at
NameAT = ""
ad = find(mod, NameAD)
if (null ad)
{ return(Count)
}
NameAT = ad.typeName
// <<<<<<< sekrboe's code here >>>>>>>>>
at = find(mod, NameAT)
if (!null at and at.type == attrEnumeration)
Count = at.size
return(Count)
} // end fCountAD()
|
Re: Print all values of a multi enumeration I thought I was able to list Username as an enumeration but now I can't. Am I mistaken or is this now a forbidden operation? Per example above, this works:
AttrType at = find (current Module, "Boolean")
int lll
for (lll = 0; lll < at.size; lll++) {
print "Value = " at.strings[lll] "\t"
print "Rel numb = " at.values[lll] "\t"
print "Color = " at.colors[lll] "\n"
}
Value = False Rel numb = 0 Color = -1 But this fails: null attribute type parameter was passed into argument position 1
AttrType at = find (current Module, "Username")
int lll
for (lll = 0; lll < at.size; lll++) {
print "Value = " at.strings[lll] "\t"
print "Rel numb = " at.values[lll] "\t"
print "Color = " at.colors[lll] "\n"
}
This fails too: AttrType at = find (current Module, "User name") OBJECTIVE: Show members of Username. Is this possible? If so how?
|
Re: Print all values of a multi enumeration Fu Lin Yiu - Fri Mar 18 13:34:56 EDT 2016 I thought I was able to list Username as an enumeration but now I can't. Am I mistaken or is this now a forbidden operation? Per example above, this works:
AttrType at = find (current Module, "Boolean")
int lll
for (lll = 0; lll < at.size; lll++) {
print "Value = " at.strings[lll] "\t"
print "Rel numb = " at.values[lll] "\t"
print "Color = " at.colors[lll] "\n"
}
Value = False Rel numb = 0 Color = -1 But this fails: null attribute type parameter was passed into argument position 1
AttrType at = find (current Module, "Username")
int lll
for (lll = 0; lll < at.size; lll++) {
print "Value = " at.strings[lll] "\t"
print "Rel numb = " at.values[lll] "\t"
print "Color = " at.colors[lll] "\n"
}
This fails too: AttrType at = find (current Module, "User name") OBJECTIVE: Show members of Username. Is this possible? If so how?
I am pretty sure that usernames are not treatable like enumerations. Since the user repository can change anytime - but enumerations are stored inside the module. Therefore I think you will have to go thru the userList. Regards, Mathias
|
Re: Print all values of a multi enumeration Fu Lin Yiu - Fri Mar 18 13:34:56 EDT 2016 I thought I was able to list Username as an enumeration but now I can't. Am I mistaken or is this now a forbidden operation? Per example above, this works:
AttrType at = find (current Module, "Boolean")
int lll
for (lll = 0; lll < at.size; lll++) {
print "Value = " at.strings[lll] "\t"
print "Rel numb = " at.values[lll] "\t"
print "Color = " at.colors[lll] "\n"
}
Value = False Rel numb = 0 Color = -1 But this fails: null attribute type parameter was passed into argument position 1
AttrType at = find (current Module, "Username")
int lll
for (lll = 0; lll < at.size; lll++) {
print "Value = " at.strings[lll] "\t"
print "Rel numb = " at.values[lll] "\t"
print "Color = " at.colors[lll] "\n"
}
This fails too: AttrType at = find (current Module, "User name") OBJECTIVE: Show members of Username. Is this possible? If so how?
There is no module attribute type as "Username". In the other case a "Boolean" is defined as a module attribute type. If you manage the users that have access to the module individually or by group then you can iterate through that list and find the users. Otherwise if you want to see the users that have change the module you need to iterate through the history and identify the users that have made changes.
Kind regards,
Costas |