Hi,
I have an attribute type with an enumeration, and I want to delete one of those values. I am trying withe the next code but it doesn't work, give a diagnostic log.
Module m = current
string enumerationType = "nameAttributeType"
string deleteValEnumeration = "valueToDelete"
AttrType att = find(m, enumerationType)
int arrColors[att.size]
int arrMap[att.size]
string arr[att.size]
int arrVal[att.size]
string arrDescs[att.size]
int i
int j = 0
for(i = 0; i < att.size-1; i++){
if(att.strings[i] != deleteValEnumeration){
arr[j] = att.strings[i]
arrVal[j] = 0
arrColors[j] = att.colors[i]
arrDescs[j] = att.descriptions[i]
arrMap[j] = i
j++
}
}
AttrType att2 = modify(att, enumerationType, arr, arrVal, arrColors, arrDescs, arrMap, err)
And the error in the DXL Editor is : -R-E- DXL: <Line:23> An unexpected error has occurred: doors.exe caused an EXCEPTION_ACCESS_VIOLATION in module doors.exe at 000000003F9CF544
-R-F- DXL: <Line:23> internal error, please submit a bug report Thank you!
Juanfergar - Fri May 31 04:59:27 EDT 2019 |
Re: Delete a value in an enumetarion attribute type Because you are deleting something , the new arrays are not the same size (att.size) as the old ones. Tested your script and yes, it crashes with exception. But if you just write out the arrays, instead of declaring them att.size and looping to copy values it will work:
|
Re: Delete a value in an enumetarion attribute type PekkaMakinen - Mon Jun 03 06:47:23 EDT 2019 Because you are deleting something , the new arrays are not the same size (att.size) as the old ones. Tested your script and yes, it crashes with exception. But if you just write out the arrays, instead of declaring them att.size and looping to copy values it will work:
If I use that code it works, but I miss all the values selected except those who doesn't change inte the enumeration, I mean, in the example, if I have objects with the value Rejected selected, it disapear. I need remove the value in the enumeration but doesn't miss the others values selected in the objects |
Re: Delete a value in an enumetarion attribute type PekkaMakinen - Mon Jun 03 06:47:23 EDT 2019 Because you are deleting something , the new arrays are not the same size (att.size) as the old ones. Tested your script and yes, it crashes with exception. But if you just write out the arrays, instead of declaring them att.size and looping to copy values it will work:
I found the error.
The problem was the size of the array as you say. If I adjust the new size it works and without the problem that you miss the values selected:
Module m = current
string enumerationType = "nameAttributeType"
string deleteValEnumeration = "valueToDelete"
AttrType att = find(m, enumerationType)
int arrColors[att.size-1]
int arrMap[att.size-1]
string arr[att.size-1]
int arrVal[att.size-1]
int i
int j = 0
for(i = 0; i < att.size; i++){
if(att.strings[i] != deleteValEnumeration){
arr[j] = att.strings[i]
arrVal[j] = 0
arrColors[j] = att.colors[i]
arrMap[j] = i
j++
}
}
AttrType att2 = modify(att, enumerationType, arr, arrVal, arrColors, arrMap, err)
Thank you!!! |