Hello, |
Re: creating a DXL attribute using a multi-valued attribute input First stab:
bool bStatus[NumEnumerations] // default setting is false
for each oChild object
{ for i=0; i<NumEnumerations; i++)
{ if (isMember(oChild, Enumeration[i])) bStatus[i] = true
}
}
Buffer bufResults = create()
for i=0; i<NumEnumerations; i++)
{ if (bStatus[i])
{ if (length(bufResults) > 0) bufResults += ", "
bufResults += Enumeration[i]
}
}
obj.attrDXLName = tempStringOf(bufResults)
delete(bufResults()
|
Re: creating a DXL attribute using a multi-valued attribute input llandale - Wed Apr 04 13:17:46 EDT 2012 First stab:
bool bStatus[NumEnumerations] // default setting is false
for each oChild object
{ for i=0; i<NumEnumerations; i++)
{ if (isMember(oChild, Enumeration[i])) bStatus[i] = true
}
}
Buffer bufResults = create()
for i=0; i<NumEnumerations; i++)
{ if (bStatus[i])
{ if (length(bufResults) > 0) bufResults += ", "
bufResults += Enumeration[i]
}
}
obj.attrDXLName = tempStringOf(bufResults)
delete(bufResults()
for each oChild object { for i=0; i<NumEnumerations; i++) { if (isMember(oChild, Enumeration[i])) bStatus[i] = true
for i=0; i<NumEnumerations; i++) { if (bStatus[i]) { if (length(bufResults) > 0) bufResults += ", " bufResults += Enumeration[i] } } obj.attrDXLName = tempStringOf(bufResults)
(after line from previously attached code: L2Status = oSource."Verification Status") and would I even need the conditions shown throughout the rest of the code if it is gathering all the values checked from each linked requirement? Also, to avoid duplication, how would I have it not display the same status shown in multiple child requirements. If 2 linked requirements both have a verification status of "Incomplete", I would not want the script to display "Incomplete, Incomplete". |
Re: creating a DXL attribute using a multi-valued attribute input SystemAdmin - Wed Apr 04 16:49:36 EDT 2012
for i=0; i<NumEnumerations; i++) { if (bStatus[i]) { if (length(bufResults) > 0) bufResults += ", " bufResults += Enumeration[i] } } obj.attrDXLName = tempStringOf(bufResults)
(after line from previously attached code: L2Status = oSource."Verification Status") and would I even need the conditions shown throughout the rest of the code if it is gathering all the values checked from each linked requirement? Also, to avoid duplication, how would I have it not display the same status shown in multiple child requirements. If 2 linked requirements both have a verification status of "Incomplete", I would not want the script to display "Incomplete, Incomplete". Typo:
This presumes NameAttr is a multi-valued enuerated attribute. This asks if the oChild attr value for that enumerated attribute includes the "i"th value. So if enumerations are A, B, C, D and the first oChild has B and C selected, bStatus will have values false, true, true, false. If the 3rd oChild has just D selected, then bStatus becomes false, true, true, true. Since there is no else bStatus[i] =false clause, bStatus[i] remains true if any of the oChildren have that enum set.
string NameAttr = "MyEnumeratedAttr",
Enum
Object oChild = current
Module mod = module(oChild)
AttrDef ad = find(mod, NameAttr)
if (null ad) {print "no such attr '" NameAttr "'\n"; halt}
if (!ad.multi) {print "not multi attr '" NameAttr "'\n"; halt}
AttrType at = ad.type
noError()
int i, NumEnums = at.size
lastError()
print "for attr '" NameAttr "' (count " NumEnums ") and object " identifier(oChild) "...\n"
print "\tEnum\tselected?\n"
for (i=0; i<NumEnums; i++)
{ Enum = at.strings[i]
print "\t[" Enum "]"
if (isMember(oChild.NameAttr, Enum)) print "\tSelected"
print "\n"
}
|
Re: creating a DXL attribute using a multi-valued attribute input llandale - Thu Apr 05 11:03:54 EDT 2012 Typo:
This presumes NameAttr is a multi-valued enuerated attribute. This asks if the oChild attr value for that enumerated attribute includes the "i"th value. So if enumerations are A, B, C, D and the first oChild has B and C selected, bStatus will have values false, true, true, false. If the 3rd oChild has just D selected, then bStatus becomes false, true, true, true. Since there is no else bStatus[i] =false clause, bStatus[i] remains true if any of the oChildren have that enum set.
string NameAttr = "MyEnumeratedAttr",
Enum
Object oChild = current
Module mod = module(oChild)
AttrDef ad = find(mod, NameAttr)
if (null ad) {print "no such attr '" NameAttr "'\n"; halt}
if (!ad.multi) {print "not multi attr '" NameAttr "'\n"; halt}
AttrType at = ad.type
noError()
int i, NumEnums = at.size
lastError()
print "for attr '" NameAttr "' (count " NumEnums ") and object " identifier(oChild) "...\n"
print "\tEnum\tselected?\n"
for (i=0; i<NumEnums; i++)
{ Enum = at.strings[i]
print "\t[" Enum "]"
if (isMember(oChild.NameAttr, Enum)) print "\tSelected"
print "\n"
}
I took a few days away from this task and now just have 2 errors haunting me.
if (L2Status == ad.name){ // checking if the attribute type is the Verification Status attribute
delete(bufResults())
Attachments attachment_14813144_Verification2.dxl |
Re: creating a DXL attribute using a multi-valued attribute input SystemAdmin - Mon Apr 16 14:01:56 EDT 2012
I took a few days away from this task and now just have 2 errors haunting me.
if (L2Status == ad.name){ // checking if the attribute type is the Verification Status attribute
delete(bufResults())
Since bufResults is a "Buffer" variable, you want:
-Louie |
Re: creating a DXL attribute using a multi-valued attribute input llandale - Mon Apr 16 14:22:08 EDT 2012
Since bufResults is a "Buffer" variable, you want:
-Louie
I've made a few changes and realized that I was not 'finding' the attribute definitions name to do the comparison and tweaked my code to the following:
for inlink in obj <-"*" do { // for all objects that have inlinks (child requirements) do this ...
oSource = source(inlink)
if (null oSource) continue
if (exists attribute "Verification Status"){ // checking for the Verification Status attribute
L2Status = oSource."Verification Status"
ad = find(oSource, NameAttr)
if (L2Status == ad.name){ // checking if the attribute is the Verification Status attribute
EnumSize = aType.size
MultiEnum = aType.strings[i]
for (i=0; i<EnumSize; i++) {
if (isMember(oSource."Verification Status", MultiEnum)) {
bStatus = true // resets to true if it exists
}
}
}
else Incomplete == true
}
Buffer bufResults = create() // creates a 'space' to hold values
for (i=0; i<EnumSize; i++) {
if (bStatus) {
if (length(bufResults) > 0) {
bufResults += "\n"
bufResults += MultiEnum[i]
}
}
}
L1Status = tempStringOf(bufResults)
obj.attrDXLName = L1Status
delete(bufResults)
}
ad = find(oSource, NameAttr)
|
Re: creating a DXL attribute using a multi-valued attribute input SystemAdmin - Mon Apr 16 14:41:11 EDT 2012
I've made a few changes and realized that I was not 'finding' the attribute definitions name to do the comparison and tweaked my code to the following:
for inlink in obj <-"*" do { // for all objects that have inlinks (child requirements) do this ...
oSource = source(inlink)
if (null oSource) continue
if (exists attribute "Verification Status"){ // checking for the Verification Status attribute
L2Status = oSource."Verification Status"
ad = find(oSource, NameAttr)
if (L2Status == ad.name){ // checking if the attribute is the Verification Status attribute
EnumSize = aType.size
MultiEnum = aType.strings[i]
for (i=0; i<EnumSize; i++) {
if (isMember(oSource."Verification Status", MultiEnum)) {
bStatus = true // resets to true if it exists
}
}
}
else Incomplete == true
}
Buffer bufResults = create() // creates a 'space' to hold values
for (i=0; i<EnumSize; i++) {
if (bStatus) {
if (length(bufResults) > 0) {
bufResults += "\n"
bufResults += MultiEnum[i]
}
}
}
L1Status = tempStringOf(bufResults)
obj.attrDXLName = L1Status
delete(bufResults)
}
ad = find(oSource, NameAttr)
At about line 7, this may be clearer:
At about line 9, "i" does not yet have a value. I think you need to move this line down into the loop:
At about line 30 I think this statement, while not needed, makes the code easier to understand:
You are still not getting the result you want; look again at some of the previous responses. -Louie |
Re: creating a DXL attribute using a multi-valued attribute input llandale - Tue Apr 17 12:20:59 EDT 2012
At about line 7, this may be clearer:
At about line 9, "i" does not yet have a value. I think you need to move this line down into the loop:
At about line 30 I think this statement, while not needed, makes the code easier to understand:
You are still not getting the result you want; look again at some of the previous responses. -Louie I have the following variables declared upfront, LinkRef lr Link inlink bool Incomplete = false // true when any linked object is "Incomplete" bool Passed = false // true when any linked object has "Passed" bool Failed = false // true when any linked object has "Failed" bool Waived = false // true when any linked object is "Waived" bool Blank = false // true when any linked object has no input string L2Status, L1Status Object oSource string NameAttr = "Verification Status" AttrDef aDef = find(mod, NameAttr) AttrType aType = aDef.type int i, EnumSize = aType.size // size of enumeration string MultiEnum[EnumSize] bool bStatus[EnumSize] // default setting is false Buffer bufResults = create() // creates a 'space' to hold values
for inlink in obj <-"*" do { // for all objects that have inlinks (child requirements) do this ...
oSource = source(inlink)
if (null oSource) continue
if (exists attribute "Verification Status"){ // checking for the Verification Status attribute
L2Status = oSource."Verification Status"
if (L2Status == NameAttr){ // checking if the name of the attribute is Verification Status
for (i=0; i<EnumSize; i++) {
MultiEnum[i] = aType.strings[i] // enumeration value names
if (isMember(oSource."Verification Status", MultiEnum[i])) {
bStatus[i] = true // resets to true if it exists
}
else Blank = false
}
}
else bufResults = " " // if the Verification Status attribute doesnt exist, return an empty buffer
for (i=0; i<EnumSize; i++) {
if (bStatus[i]) {
if (length(bufResults) > 0) {
bufResults += "\n"
bufResults += MultiEnum[i]
}
}
}
}
}
if (Blank) L1Status = " " // no input keep Blank
else L1Status = tempStringOf(bufResults)
obj.attrDXLName = L1Status // DXL attribute column
delete(bufResults)
unassigned array element (bStatus[0])
|
Re: creating a DXL attribute using a multi-valued attribute input SystemAdmin - Wed Apr 18 14:48:49 EDT 2012 I have the following variables declared upfront, LinkRef lr Link inlink bool Incomplete = false // true when any linked object is "Incomplete" bool Passed = false // true when any linked object has "Passed" bool Failed = false // true when any linked object has "Failed" bool Waived = false // true when any linked object is "Waived" bool Blank = false // true when any linked object has no input string L2Status, L1Status Object oSource string NameAttr = "Verification Status" AttrDef aDef = find(mod, NameAttr) AttrType aType = aDef.type int i, EnumSize = aType.size // size of enumeration string MultiEnum[EnumSize] bool bStatus[EnumSize] // default setting is false Buffer bufResults = create() // creates a 'space' to hold values
for inlink in obj <-"*" do { // for all objects that have inlinks (child requirements) do this ...
oSource = source(inlink)
if (null oSource) continue
if (exists attribute "Verification Status"){ // checking for the Verification Status attribute
L2Status = oSource."Verification Status"
if (L2Status == NameAttr){ // checking if the name of the attribute is Verification Status
for (i=0; i<EnumSize; i++) {
MultiEnum[i] = aType.strings[i] // enumeration value names
if (isMember(oSource."Verification Status", MultiEnum[i])) {
bStatus[i] = true // resets to true if it exists
}
else Blank = false
}
}
else bufResults = " " // if the Verification Status attribute doesnt exist, return an empty buffer
for (i=0; i<EnumSize; i++) {
if (bStatus[i]) {
if (length(bufResults) > 0) {
bufResults += "\n"
bufResults += MultiEnum[i]
}
}
}
}
}
if (Blank) L1Status = " " // no input keep Blank
else L1Status = tempStringOf(bufResults)
obj.attrDXLName = L1Status // DXL attribute column
delete(bufResults)
unassigned array element (bStatus[0])
Oops, you do need to initialize that array: for (i=0; i<EnumSize; i++) bStatus[i] = false
L2Status = oSource."Verification Status"
if (L2Status == NameAttr){ // checking if the name of the attribute is Verification Status
|
Re: creating a DXL attribute using a multi-valued attribute input llandale - Wed Apr 18 17:37:47 EDT 2012 Oops, you do need to initialize that array: for (i=0; i<EnumSize; i++) bStatus[i] = false
L2Status = oSource."Verification Status"
if (L2Status == NameAttr){ // checking if the name of the attribute is Verification Status
I thought I had this completed but my inputs were misleading.
for inlink in obj <-"*" do {
oSource = source(inlink)
if (null oSource) continue
Module mod = module(oSource)
AttrDef aDef = find(mod, NameAttr)
AttrType aType = aDef.type
int i, EnumSize = aType.size // size of enumeration
string MultiEnum[EnumSize]
bool bStatus[EnumSize] // default setting is false
if (exists attribute "Verification Status"){ // checking for the Verification Status attribute
if (null aDef) {print "no such attr" NameAttr "\n"; halt}
if (aDef.multi) {print "multi attr: " NameAttr "\n"}
noError()
lastError()
print "for attr " NameAttr " (count " EnumSize ") and object " identifier(oSource) "...\n"
for (i=0; i<EnumSize; i++) {
bStatus[i] = false
MultiEnum[i] = aType.strings[i] // enumeration value names
print MultiEnum[i] "\n"
if (isMember(oSource.NameAttr, MultiEnum[i])) then {
print "\t CHECKED !!!"
print "\n"
bStatus[i] = true // resets to true if it exists
print "\t bR STATUS: " stringOf(bufResults) //prints status of buffer contents
print "\n \n"
}
else Blank = true // nothing 'checked/selected'
//else bufResults = " "
}
for (i=0; i<EnumSize; i++) {
if (bStatus[i]){
if (length(bufResults) >= 0){
bufResults += "\n"
bufResults += MultiEnum[i]
print "\t bufResult: " stringOf(bufResults)
print "\n \n"
}
}
}
} // ENDS attribute exists statement
else bufResults = "" // the Verification Status attribute doesnt exist, return an empty buffer
} //ENDS inlink if statement
LStatus = tempStringOf(bufResults)
obj.attrDXLName = LStatus // DXL attribute column
delete(bufResults)
|
Re: creating a DXL attribute using a multi-valued attribute input SystemAdmin - Mon May 21 16:22:49 EDT 2012
I thought I had this completed but my inputs were misleading.
for inlink in obj <-"*" do {
oSource = source(inlink)
if (null oSource) continue
Module mod = module(oSource)
AttrDef aDef = find(mod, NameAttr)
AttrType aType = aDef.type
int i, EnumSize = aType.size // size of enumeration
string MultiEnum[EnumSize]
bool bStatus[EnumSize] // default setting is false
if (exists attribute "Verification Status"){ // checking for the Verification Status attribute
if (null aDef) {print "no such attr" NameAttr "\n"; halt}
if (aDef.multi) {print "multi attr: " NameAttr "\n"}
noError()
lastError()
print "for attr " NameAttr " (count " EnumSize ") and object " identifier(oSource) "...\n"
for (i=0; i<EnumSize; i++) {
bStatus[i] = false
MultiEnum[i] = aType.strings[i] // enumeration value names
print MultiEnum[i] "\n"
if (isMember(oSource.NameAttr, MultiEnum[i])) then {
print "\t CHECKED !!!"
print "\n"
bStatus[i] = true // resets to true if it exists
print "\t bR STATUS: " stringOf(bufResults) //prints status of buffer contents
print "\n \n"
}
else Blank = true // nothing 'checked/selected'
//else bufResults = " "
}
for (i=0; i<EnumSize; i++) {
if (bStatus[i]){
if (length(bufResults) >= 0){
bufResults += "\n"
bufResults += MultiEnum[i]
print "\t bufResult: " stringOf(bufResults)
print "\n \n"
}
}
}
} // ENDS attribute exists statement
else bufResults = "" // the Verification Status attribute doesnt exist, return an empty buffer
} //ENDS inlink if statement
LStatus = tempStringOf(bufResults)
obj.attrDXLName = LStatus // DXL attribute column
delete(bufResults)
I think you need to set bstatusall to false before your link loop. Inside the link loop set bstatus[i] to true if that linked object so indicates. Display results after the link loop:
set all bstatus[x] = false
for each link
{ for each enumeration
if the linked object has this enumeration selected then bstatus[i] = true
}
for each enumeration
if bstatus[i] is true then add Enums[i] to results
display results
|
Re: creating a DXL attribute using a multi-valued attribute input llandale - Tue May 22 09:16:04 EDT 2012 I think you need to set bstatusall to false before your link loop. Inside the link loop set bstatus[i] to true if that linked object so indicates. Display results after the link loop:
set all bstatus[x] = false
for each link
{ for each enumeration
if the linked object has this enumeration selected then bstatus[i] = true
}
for each enumeration
if bstatus[i] is true then add Enums[i] to results
display results
bStatus is declared in the link loop. If I move it outside the loop, then the other variables have to be moved and declared before it, but the oSource variable depends on my inlink variable, which isn't assigned until the link loop, and returns an unassigned variable error since each one depends upon the other.
set all bStatus[EnumSize] = false
if (exists attribute "Verification Status"){ ...
-E- DXL: incorrect arguments for (=) -E- DXL: incorrect arguments for function (all) -E- DXL: incorrect arguments for function (set)
void set (bStatus[EnumSize]) = false
for inlink in all obj <-"*" do { ...
-E- DXL: incorrect arguments for (<-) -E- DXL: incorrect arguments for (do)
for bStatus in all oSource {
|
Re: creating a DXL attribute using a multi-valued attribute input SystemAdmin - Tue May 22 11:30:33 EDT 2012
bStatus is declared in the link loop. If I move it outside the loop, then the other variables have to be moved and declared before it, but the oSource variable depends on my inlink variable, which isn't assigned until the link loop, and returns an unassigned variable error since each one depends upon the other.
set all bStatus[EnumSize] = false
if (exists attribute "Verification Status"){ ...
-E- DXL: incorrect arguments for (=) -E- DXL: incorrect arguments for function (all) -E- DXL: incorrect arguments for function (set)
void set (bStatus[EnumSize]) = false
for inlink in all obj <-"*" do { ...
-E- DXL: incorrect arguments for (<-) -E- DXL: incorrect arguments for (do)
for bStatus in all oSource {
bStatus is declared in the link loop. If I move it outside the loop, then the other variables have to be moved and declared before it, but the oSource variable depends on my inlink variable, which isn't assigned until the link loop, and returns an unassigned variable error since each one depends upon the other. This is inadequate logic; the order in which variables are declared, and in which context, has little to do with the order in which their values are determined; you only have a problem if their values are circular; A depends on B and B depends on A. Anyway, maybe I'm old-fashioned but it should be rare to declare a variable other than in the function's context; declarations inside usually make it harder to read; and if it is easier to read then probabaly your function is far too big. Overall, I think you said you want to display an enumerated value if any of the linked objects have that value. If so, there is no getting around this (or similar) logic:
Your "exists" statement is still faulty; it will find it in the "current Module", but is the module containing "obj" or the module containing "oSource" currently current? (it's probably "obj" but you want to know if it's in "oSource") You don't need that statement if you use function "probeAttr_" as that function gracefully handles when the attr doesn't exist and returns null. -Louie |
Re: creating a DXL attribute using a multi-valued attribute input llandale - Tue May 22 13:39:17 EDT 2012 bStatus is declared in the link loop. If I move it outside the loop, then the other variables have to be moved and declared before it, but the oSource variable depends on my inlink variable, which isn't assigned until the link loop, and returns an unassigned variable error since each one depends upon the other. This is inadequate logic; the order in which variables are declared, and in which context, has little to do with the order in which their values are determined; you only have a problem if their values are circular; A depends on B and B depends on A. Anyway, maybe I'm old-fashioned but it should be rare to declare a variable other than in the function's context; declarations inside usually make it harder to read; and if it is easier to read then probabaly your function is far too big. Overall, I think you said you want to display an enumerated value if any of the linked objects have that value. If so, there is no getting around this (or similar) logic:
Your "exists" statement is still faulty; it will find it in the "current Module", but is the module containing "obj" or the module containing "oSource" currently current? (it's probably "obj" but you want to know if it's in "oSource") You don't need that statement if you use function "probeAttr_" as that function gracefully handles when the attr doesn't exist and returns null. -Louie
The entire script ...
Module mod = current
string DxlCode = readFile("C:\\Program Files/IBM/Rational/DOORS/9.3/lib/dxl/addins/MyDXL/L1 Verification.dxl")
AttrDef ad = create(object dxl DxlCode type "String" attribute "L1-L2 Verification Status")
Module mod = current
LinkRef lr
Link inlink
bool Incomplete = false // true when any linked object is "Incomplete"
bool Passed = false // true when any linked object has "Passed"
bool Failed = false // true when any linked object has "Failed"
bool Waived = false // true when any linked object is "Waived"
bool Blank = false // true when any linked object has no input
string L1Status
Object oSource
string NameAttr = "Verification Status"
Buffer bufResults = create() // creates a 'space' to hold values
AttrDef aDef = find(mod, NameAttr)
AttrType aType = aDef.type
int i, EnumSize = aType.size // size of enumeration
string MultiEnum[EnumSize]
bool bStatus[EnumSize] = false // default setting is false
// Checking for null obj
if (null obj){
obj = obj__()
display "obj__() used: " identifier(obj) ""
}
// Open up modules that target this Object for links
for lr in obj <-"*" do {
read(fullName(source(lr)), false, true) // Open linked module, even if it's already open
}
for inlink in obj <-"*" do { // for all objects that have inlinks (child requirements) do this ...
oSource = source(inlink)
if (null oSource) continue
for (i=0; i<EnumSize; i++) {
bStatus[i] = false
MultiEnum[i] = aType.strings[i] // enumeration value names
if (isMember(oSource.NameAttr, MultiEnum[i])) then {
bStatus[i] = true // resets to true if it exists
}
else bStatus[i] = false
}
}
for (i=0; i<EnumSize; i++) {
if (bStatus[i]){
// if (length(bufResults) >= 0){
bufResults += "\n"
bufResults += MultiEnum[i]
// }
}
}
L1Status = tempStringOf(bufResults)
obj.attrDXLName = L1Status // DXL attribute column
delete(bufResults)
-R-E- DXL: unassigned array element (bStatus[1])
|
Re: creating a DXL attribute using a multi-valued attribute input SystemAdmin - Tue May 22 17:42:41 EDT 2012
The entire script ...
Module mod = current
string DxlCode = readFile("C:\\Program Files/IBM/Rational/DOORS/9.3/lib/dxl/addins/MyDXL/L1 Verification.dxl")
AttrDef ad = create(object dxl DxlCode type "String" attribute "L1-L2 Verification Status")
Module mod = current
LinkRef lr
Link inlink
bool Incomplete = false // true when any linked object is "Incomplete"
bool Passed = false // true when any linked object has "Passed"
bool Failed = false // true when any linked object has "Failed"
bool Waived = false // true when any linked object is "Waived"
bool Blank = false // true when any linked object has no input
string L1Status
Object oSource
string NameAttr = "Verification Status"
Buffer bufResults = create() // creates a 'space' to hold values
AttrDef aDef = find(mod, NameAttr)
AttrType aType = aDef.type
int i, EnumSize = aType.size // size of enumeration
string MultiEnum[EnumSize]
bool bStatus[EnumSize] = false // default setting is false
// Checking for null obj
if (null obj){
obj = obj__()
display "obj__() used: " identifier(obj) ""
}
// Open up modules that target this Object for links
for lr in obj <-"*" do {
read(fullName(source(lr)), false, true) // Open linked module, even if it's already open
}
for inlink in obj <-"*" do { // for all objects that have inlinks (child requirements) do this ...
oSource = source(inlink)
if (null oSource) continue
for (i=0; i<EnumSize; i++) {
bStatus[i] = false
MultiEnum[i] = aType.strings[i] // enumeration value names
if (isMember(oSource.NameAttr, MultiEnum[i])) then {
bStatus[i] = true // resets to true if it exists
}
else bStatus[i] = false
}
}
for (i=0; i<EnumSize; i++) {
if (bStatus[i]){
// if (length(bufResults) >= 0){
bufResults += "\n"
bufResults += MultiEnum[i]
// }
}
}
L1Status = tempStringOf(bufResults)
obj.attrDXLName = L1Status // DXL attribute column
delete(bufResults)
-R-E- DXL: unassigned array element (bStatus[1])
Funny that this code works: bool bStatus[EnumSize] = false // default setting is false
bool bStatus[EnumSize] int i; for (i = 0; i < EnumSize; i++) bStatus[i] = false
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: creating a DXL attribute using a multi-valued attribute input Mathias Mamsch - Wed May 23 07:48:22 EDT 2012
Funny that this code works: bool bStatus[EnumSize] = false // default setting is false
bool bStatus[EnumSize] int i; for (i = 0; i < EnumSize; i++) bStatus[i] = false
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
I had it w/o the "= false" initally, but even after removing it, I am still recieving an error for this line
for (i=0; i<EnumSize; i++) bStatus[i] = false { ...
-R-E- DXL: array bounds exceeded (4)
for (i=0; i<EnumSize; i++) {
bStatus[i] = false
for (i=0; i<EnumSize; i++) {
bStatus[i] = false
if (bStatus[i]){
if (length(bufResults) >= 0){
bufResults += "\n"
bufResults += MultiEnum[i]
}
}
}
|
Re: creating a DXL attribute using a multi-valued attribute input SystemAdmin - Wed May 23 11:47:40 EDT 2012
I had it w/o the "= false" initally, but even after removing it, I am still recieving an error for this line
for (i=0; i<EnumSize; i++) bStatus[i] = false { ...
-R-E- DXL: array bounds exceeded (4)
for (i=0; i<EnumSize; i++) {
bStatus[i] = false
for (i=0; i<EnumSize; i++) {
bStatus[i] = false
if (bStatus[i]){
if (length(bufResults) >= 0){
bufResults += "\n"
bufResults += MultiEnum[i]
}
}
}
Maybe you misinterpreted my statement. The code should be like that:
Module mod = current
LinkRef lr
Link inlink
bool Incomplete = false // true when any linked object is "Incomplete"
bool Passed = false // true when any linked object has "Passed"
bool Failed = false // true when any linked object has "Failed"
bool Waived = false // true when any linked object is "Waived"
bool Blank = false // true when any linked object has no input
string L1Status
Object oSource
string NameAttr = "Verification Status"
Buffer bufResults = create() // creates a 'space' to hold values
AttrDef aDef = find(mod, NameAttr)
AttrType aType = aDef.type
int i, EnumSize = aType.size // size of enumeration
string MultiEnum[EnumSize]
bool bStatus[EnumSize]
for (i=0; i<EnumSize; i++) bStatus[i] = false
// Checking for null obj
if (null obj){
obj = obj__()
display "obj__() used: " identifier(obj) "" // Display? Below you use 'attrDXLName', so I guess this is test code?
}
// Open up modules that target this Object for links
for lr in obj <-"*" do {
ModuleVersion mv = sourceVersion lr // want this to work for baseline sets? Use the correct source version!
if (null data mv) load(mv, false)
}
for inlink in obj <- "*" do { // for all objects that have inlinks (child requirements) do this ...
oSource = source(inlink)
if (null oSource) continue
for (i=0; i<EnumSize; i++) {
MultiEnum[i] = aType.strings[i]
bStatus[i] = isMember(oSource.NameAttr, MultiEnum[i]) // this is just a shorter version of your code
}
}
for (i=0; i<EnumSize; i++) {
if (bStatus[i]) {
if (length(bufResults) >= 0) bufResults += "\n" // This way results will be nicely separated
bufResults += MultiEnum[i]
}
}
L1Status = tempStringOf(bufResults)
obj.attrDXLName = L1Status
delete(bufResults)
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: creating a DXL attribute using a multi-valued attribute input Mathias Mamsch - Wed May 23 18:04:28 EDT 2012
Maybe you misinterpreted my statement. The code should be like that:
Module mod = current
LinkRef lr
Link inlink
bool Incomplete = false // true when any linked object is "Incomplete"
bool Passed = false // true when any linked object has "Passed"
bool Failed = false // true when any linked object has "Failed"
bool Waived = false // true when any linked object is "Waived"
bool Blank = false // true when any linked object has no input
string L1Status
Object oSource
string NameAttr = "Verification Status"
Buffer bufResults = create() // creates a 'space' to hold values
AttrDef aDef = find(mod, NameAttr)
AttrType aType = aDef.type
int i, EnumSize = aType.size // size of enumeration
string MultiEnum[EnumSize]
bool bStatus[EnumSize]
for (i=0; i<EnumSize; i++) bStatus[i] = false
// Checking for null obj
if (null obj){
obj = obj__()
display "obj__() used: " identifier(obj) "" // Display? Below you use 'attrDXLName', so I guess this is test code?
}
// Open up modules that target this Object for links
for lr in obj <-"*" do {
ModuleVersion mv = sourceVersion lr // want this to work for baseline sets? Use the correct source version!
if (null data mv) load(mv, false)
}
for inlink in obj <- "*" do { // for all objects that have inlinks (child requirements) do this ...
oSource = source(inlink)
if (null oSource) continue
for (i=0; i<EnumSize; i++) {
MultiEnum[i] = aType.strings[i]
bStatus[i] = isMember(oSource.NameAttr, MultiEnum[i]) // this is just a shorter version of your code
}
}
for (i=0; i<EnumSize; i++) {
if (bStatus[i]) {
if (length(bufResults) >= 0) bufResults += "\n" // This way results will be nicely separated
bufResults += MultiEnum[i]
}
}
L1Status = tempStringOf(bufResults)
obj.attrDXLName = L1Status
delete(bufResults)
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Now reading your first statement again, I figure there is still an error in the logic. You probably want this:
for inlink in obj <- "*" do { // for all objects that have inlinks (child requirements) do this ...
oSource = source(inlink)
if (null oSource) continue
for (i=0; i<EnumSize; i++) {
MultiEnum[i] = aType.strings[i]
// if ANY inlink has this value, set it to true
// make sure it stays true, even if this object does NOT have the value set.
bStatus[i] = bStatus[i] || isMember(oSource.NameAttr, MultiEnum[i])
}
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: creating a DXL attribute using a multi-valued attribute input Mathias Mamsch - Wed May 23 18:08:50 EDT 2012
Now reading your first statement again, I figure there is still an error in the logic. You probably want this:
for inlink in obj <- "*" do { // for all objects that have inlinks (child requirements) do this ...
oSource = source(inlink)
if (null oSource) continue
for (i=0; i<EnumSize; i++) {
MultiEnum[i] = aType.strings[i]
// if ANY inlink has this value, set it to true
// make sure it stays true, even if this object does NOT have the value set.
bStatus[i] = bStatus[i] || isMember(oSource.NameAttr, MultiEnum[i])
}
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
All this time I thought this line was in both my for loops, but it was supposed to be declared upfront ... sigh :/ for (i=0; i<EnumSize; i++) bStatus[i] = false
|
Re: creating a DXL attribute using a multi-valued attribute input SystemAdmin - Tue May 22 17:42:41 EDT 2012
The entire script ...
Module mod = current
string DxlCode = readFile("C:\\Program Files/IBM/Rational/DOORS/9.3/lib/dxl/addins/MyDXL/L1 Verification.dxl")
AttrDef ad = create(object dxl DxlCode type "String" attribute "L1-L2 Verification Status")
Module mod = current
LinkRef lr
Link inlink
bool Incomplete = false // true when any linked object is "Incomplete"
bool Passed = false // true when any linked object has "Passed"
bool Failed = false // true when any linked object has "Failed"
bool Waived = false // true when any linked object is "Waived"
bool Blank = false // true when any linked object has no input
string L1Status
Object oSource
string NameAttr = "Verification Status"
Buffer bufResults = create() // creates a 'space' to hold values
AttrDef aDef = find(mod, NameAttr)
AttrType aType = aDef.type
int i, EnumSize = aType.size // size of enumeration
string MultiEnum[EnumSize]
bool bStatus[EnumSize] = false // default setting is false
// Checking for null obj
if (null obj){
obj = obj__()
display "obj__() used: " identifier(obj) ""
}
// Open up modules that target this Object for links
for lr in obj <-"*" do {
read(fullName(source(lr)), false, true) // Open linked module, even if it's already open
}
for inlink in obj <-"*" do { // for all objects that have inlinks (child requirements) do this ...
oSource = source(inlink)
if (null oSource) continue
for (i=0; i<EnumSize; i++) {
bStatus[i] = false
MultiEnum[i] = aType.strings[i] // enumeration value names
if (isMember(oSource.NameAttr, MultiEnum[i])) then {
bStatus[i] = true // resets to true if it exists
}
else bStatus[i] = false
}
}
for (i=0; i<EnumSize; i++) {
if (bStatus[i]){
// if (length(bufResults) >= 0){
bufResults += "\n"
bufResults += MultiEnum[i]
// }
}
}
L1Status = tempStringOf(bufResults)
obj.attrDXLName = L1Status // DXL attribute column
delete(bufResults)
-R-E- DXL: unassigned array element (bStatus[1])
It makes it easier if you give the line number generating such DXL errors. I have no clue about the wierd errors you expressed; I don't see how you could get them. But I wonder... [1] Perhaps you get an explicit error after turning off AutoDeclare. [2] Perhaps there is some code in play we don't see, such as in your top context. [3] You get different results when you insert this Attr-DXL into a column of a clean Standard view. I have seen attr-DXL and layout context issues ("obj" and "attrDXLName" are wrong ) for views containing a few such columns. [4] This line of code makes my hackles crawl for reason's I don't know:
There remains a fundamental structural problem: the code presumes that the current module and also ALL modules that source links to it have that attribute "Verification Status" AND they all have the same enumerations. Your code will fail rudely otherwise. The logic of the following lines should be within the link loop:
-Louie This line should be moved up, perhaps where you initialize bStatus[i] = false
Seems to me you should "halt" if "obj" is null; but maybe function "obj__()" (which I've never used) has some magic I don't understand. I would do nothing when "obj" isDeleted. I would ignore the link when "oSource" isDeleted. I would be tempted to make this Attr-DXL of type Enumeration with the correct enumerations(instead of type "string"). Then this line:
Since I have OCD I would tweak your deploy code:
|