Print all values of a multi enumeration

Hi,
is there a posibility with dxl to find out all values af a multi valued attribute type?

like i can print all attributes of a module i'd like to know all values of an type to create a new attribute for each value of a multi valued type...

thanks for help.
haiderti - Tue Nov 24 05:10:36 EST 2009

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"
}


/Kristian

Re: Print all values of a multi enumeration
haiderti - Tue Nov 24 10:35:24 EST 2009

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"
}


/Kristian

ok. that works. Thanks!

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
doors36677 - Tue Nov 24 12:59:18 EST 2009

haiderti - Tue Nov 24 10:35:24 EST 2009
ok. that works. Thanks!

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

Your approach might be considered doing it the hard way.

Either a layoutDxl or attributeDxl might prove easier.

Re: Print all values of a multi enumeration
Mathias Mamsch - Tue Nov 24 15:42:33 EST 2009

haiderti - Tue Nov 24 10:35:24 EST 2009
ok. that works. Thanks!

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

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).

The following code shows you how to insert a bunch of DXL columns:
 

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
haiderti - Wed Nov 25 03:16:55 EST 2009

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).

The following code shows you how to insert a bunch of DXL columns:
 

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]

Hey,

thanks a lot Mathias.
That works fine :)

Regards Tim

Re: Print all values of a multi enumeration
llandale - Wed Nov 25 10:16:30 EST 2009

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()


>Louie

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
Value = True    Rel numb = 1    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
Mathias Mamsch - Mon Mar 21 06:14:45 EDT 2016

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
Value = True    Rel numb = 1    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
Costas..Aravidis - Tue Mar 22 03:39:21 EDT 2016

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
Value = True    Rel numb = 1    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