Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Trigger Trouble
Topic Summary:
Created On: 15-Sep-2004 13:27
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
Answer This question was answered by Frank Held, on Wednesday, September 22, 2004 8:41 AM

Answer:
The first Trigger changes the current-settings, so current is not what the second trigger expects when it starts. To avoid this trouble I use:

Trigger trg = current()
Object o = object(trg)
Module m = module(o)
 15-Sep-2004 13:27
User is offline View Users Profile Print this message


Frank Held

Posts: 14
Joined: 16-Jul-2004

I have the modules Requirements, Testdef and Test. In Requirements-module there is a Trigger defined, updating the Status of linked objects in the Testdefmodul when a Requirementsstatus changes. Also there is a Trigger in the Testdef-module updating linked objects in the Testmodule if a Testdefinitionobject is modified.
Actually both trigger do their job, except the situation that I change a req. so that the "Requirements status has changed" trigger adapts the status of linked Testdefinitions. But if the "Testdefinition status has changed" trigger starts, it changes the status of Testobjekts not linked to modified Testdefinitions and the right Objects are untouched.

I supposed that's a problem with the triggerpriority, but I was wrong.




Requirements Trigger:
/**********************************************************************************
Trigger t = trigger ("Requirements status has changed",
module->"SRS"->attribute->"status",
post,
modify,
27,
"#include </addins/scripte/trigger/reqstatus.dxl>")
*/


Object o = current Object
Object osrc = null
Module m = current
Module msrc = null
Link lnk = null
bool op = false
bool nolnk = false
string status = ""
string src = ""


if (!open module "Testdef") {
op = true
}
msrc = edit("Testdef", true)

for lnk in o <- "*" do {
src = source(lnk)
if (src=="Testdef) {
nolnk = true
osrc = source(lnk)
osrc."status" = "to clarify"
}
}

if (!nolnk) {
//create Object in module Testdef and link it to the current object
}

if(op) {
save msrc
close msrc
}

refresh m


Testdefinition Trigger:
/**********************************************************************************
Trigger t = trigger ("Testdefinition status has changed",
module->"Testdef"->attribute->"status",
post,
modify,
30,
"#include </addins/scripte/trigger/Testdefstatus.dxl>")
*/



Object o = current Object
Object osrc = null
Module m = current Module
Module msrc = null
Link lnk = null
string status = o."status"
bool op = false

Link getLink(string src, Object o) {
Link tmplnk = null
Link lnk = null
string tmpsrc = ""
for tmplnk in o <- "*" do {
tmpsrc = source(tmplnk)
if ( tmpsrc == src) {
lnk = tmplnk
}
}
return lnk
}

if (!open module "Test") {
op = true
}

msrc = edit("Test", true)

lnk = getLink("Test", o) //there can be only one link

if (lnk==null && status=="accepted") {
//create new Object in Test-Module and link it to o
} else if (lnk!=null) {
osrc = source(lnk)
osrc."status" = "not tested"
}

if (op) {
save msrc
close msrc
}

refresh m



-------------------------
Frank
Report this to a Moderator Report this to a Moderator
 21-Sep-2004 22:54
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

I'm having trouble following all this, but have the following observations:

[0] Your forum "reply" window has an "Attach Code" button. That keeps the leading white-space in tact making these scripts MUCH easier to read; rather than copying the code straight into the window.
[1] "status" is a built in function, and so makes for a lousy variable name. Eventually this sort of naming WILL byte you in the bytt. Change it to "Status".
[2] These link functions deal with module BASE names (e.g. "Test"), rather than module full names (e.g. "/MyProject/MyFolder/Test"). This only works if the module's in question are ALL in the same folder and that folder is current. When dealing with links, its better to get the ModName_ source and then get the fullName of that; this allows you to deal with linked partners in other folders.
[3] Do your triggers work correctly when you modify the triggered attibutes with DXL? That is, instead of just testing the trigger by modifying with keyboard and mouse, run a simple DXL that modifies it:
(current Object)."status" = "New Value". Its possible the "post modify" doesn't actually trigger from DXL.

- Louie
Report this to a Moderator Report this to a Moderator
 22-Sep-2004 08:41
User is offline View Users Profile Print this message


Frank Held

Posts: 14
Joined: 16-Jul-2004

Answer Answer
The first Trigger changes the current-settings, so current is not what the second trigger expects when it starts. To avoid this trouble I use:

Trigger trg = current()
Object o = object(trg)
Module m = module(o)

-------------------------
Frank
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.