I have an enumerate-type multi-valued attribute in the module in which I am working.
The appearance is as follows:
// as it appears in the attribute column
val1
vals-2
vals3
// below is what is written in my script to turn the contents this attribute
// into a string (for this particular object)
string ovp = o."AttribName" // I have assigned it to a string in this manner
If I print the string, it prints out in a column format, like it appears in the attribute column. How has the new line been defined in this string?
I would like to use the new line definition to put each of the enumerate values into a string array (string arr[size], for clarity as I may not be using the right terms).
I am sure there is a way, but I am only two weeks into using DXL, and am at a loss on how to do this, or if there would be another way to do it that might be easier.
I have searched as much as I am able with the keywords that I know.
Thanks in advance for any help or direction. I will keep trying in the mean-time and see what I come up with. I assume that if I find an answer, I can update this question with it.
So there is probably a better way to do this, by querying the attribute definition and then using the 'isMember' function- but this way will return a string array, which you requested.
Object o = current
string s = o."Test Enum" ""
int x = 0
int y = 0
int size = 0
if ( s != "" ) {
size++
}
for ( x = 0 ; x < length ( s ) ; x++ ) {
if ( s [ x ] == '\n' ) {
size++
}
}
string arr[size]
size = 0
for ( x = 0 ; x < length ( s ) ; x++ ) {
if ( s [ x ] == '\n' ) {
arr[ size ] = s [ y : x - 1 ]
y = x + 1
size++
}
}
arr[ size ] = s [ y : ]
Of note- this first checks the size of the array, then defines it. Multiple selected attributes have a '\n' as a delimiter, but the last entry won't have that.