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
Topic Summary: Trigger on a module open event
Created On: 15-Mar-2007 20:41
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 Reik Schroeder, on Monday, March 26, 2007 7:03 PM

Answer:
Hi Louie,

Don't want to be the wisenheimer,
but I've added some comments to your statements

quote:

Originally posted by: Louie Landale
Have read the thread. I haven't tested recently, but this is what I recall:


[] I don't think you can get the 'Module' handle of a module that's not yet open; which will happen for PRE module open triggers. POST open module triggers work OK; Module mCurr = current should do it.


Not yet the module handle, but the name of module to be opened with function
string module(Trigger)

I would suggest to never use current module handle within trigger code, because it may not give you everytime the module you want to process! It may work for module open triggers (not sure if it really does in any circumstances ), but for other trigger types it can be really confusing. There could be some error messages about not defined attributes or something else which not concerns the module you think the trigger should work on.

quote:


[] The 'module' of a trigger, IIRC, is the module that houses the trigger and not the one being fired. In your case you've put the trigger in the database and its not stored in a module.


That's not correct. The function will return the current version of module that fires the trigger or if not available null.
To get the storage point of trigger you may use
string stored(Trigger)
BTW: To get the (baselined) version of triggering module you need to add a second paramter to module function:
Module module (Trigger, int)
This second parameter should be 0, as described in DXL reference manual.

quote:


[] Your include statement will only work if EVERYONE has Test.dxl loaded in the root of their C drive. Since its probably only on YOUR C drive, your code that sets the trigger should probably read the file into a variable and put the variable in the trigger call. string TriggerCode = readFile("c:/Test.dxl").


Good idea!

quote:


[] Your trigger code probably wants a check for Visible and link module status; if (isVisible(mCurr)) halt; if (type(module(fullName(mCurr))) != "Formal") halt.


Really good hint. Would suggest to check for correct module version sometimes to.



quote:


- Louie


Greetings
Reik
 15-Mar-2007 20:41
User is offline View Users Profile Print this message


Tarun Inabathuni

Posts: 59
Joined: 18-Jan-2005

Hi

I am trying to deploy a trigger , when the user tries to open a module by clicking on it or through a Link
but the catch is i need to get the name of the module which he is trying to open..i.e the module on which the trigger is activated.. i tried the following code

Trigger t = trigger("init", project->all->module->formal->all , post,open, 10,"#include <C:\test.dxl>")

but iam unable to get the Module name in the test.dxl program
is there a way to do this..

Regards
Tarun
Report this to a Moderator Report this to a Moderator
 15-Mar-2007 21:10
User is offline View Users Profile Print this message


Shawn Stepper

Posts: 96
Joined: 6-Aug-2004

How about using:

Module m = module(t)

Where t is the trigger?

-------------------------
Shawn Stepper
shawn.e.stepper@wellsfargo.com
Report this to a Moderator Report this to a Moderator
 19-Mar-2007 14:18
User is offline View Users Profile Print this message


Tarun Inabathuni

Posts: 59
Joined: 18-Jan-2005

i tried to do that but the program does not recognise t anymore
it gives me undeclared trigger error
Report this to a Moderator Report this to a Moderator
 19-Mar-2007 16:07
User is offline View Users Profile Print this message


Tony Goodman

Posts: 1098
Joined: 12-Sep-2002

Try
Module m = module(current Trigger)

-------------------------
Tony Goodman
http://www.smartdxl.com
Report this to a Moderator Report this to a Moderator
 19-Mar-2007 17:55
User is offline View Users Profile Print this message


Tarun Inabathuni

Posts: 59
Joined: 18-Jan-2005

This is a pre operation trigger so it is giving the previous module still..
Report this to a Moderator Report this to a Moderator
 20-Mar-2007 08:44
User is offline View Users Profile Print this message


Tony Goodman

Posts: 1098
Joined: 12-Sep-2002

In your original post, it is a post-open trigger.

Don't forget that the trigger will fire for modules opened (not visible) by doors as a result of layout DXL etc.
Have you checked this?

-------------------------
Tony Goodman
http://www.smartdxl.com

Edited: 20-Mar-2007 at 08:46 by Tony Goodman
Report this to a Moderator Report this to a Moderator
 20-Mar-2007 13:49
User is offline View Users Profile Print this message


Tarun Inabathuni

Posts: 59
Joined: 18-Jan-2005

Yes, i did check the pre
Trigger t = trigger("init", project->all->module->formal->all , pre,open, 10,"#include <C:\test.dxl>")
but i still face the same problem.
Is there any other type of trigger i can use to solve this problem..
Report this to a Moderator Report this to a Moderator
 20-Mar-2007 14:55
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

Hi Tarun,

it should work to use the function
string module (Trigger)

It will return the name (not fullName) of module which fires the trigger.

So your example code could be:
Trigger t = trigger("init", project->all->module->formal->all , pre, open, 10,"print (string module (current Trigger))");

BTW: I would suggest to not use include statements within trigger code (for development it might be usefull), because this can cause errors on user machines wich have not installed the include file.
Remember the trigger is active in database for all users from all clients!

Greetings
Reik

-------------------------
Evosoft GmbH
for Siemens Industry Sector


Berlin, Germany
Report this to a Moderator Report this to a Moderator
 23-Mar-2007 16:08
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Have read the thread. I haven't tested recently, but this is what I recall:

[] I don't think you can get the 'Module' handle of a module that's not yet open; which will happen for PRE module open triggers. POST open module triggers work OK; Module mCurr = current should do it.

[] The 'module' of a trigger, IIRC, is the module that houses the trigger and not the one being fired. In your case you've put the trigger in the database and its not stored in a module.

[] Your include statement will only work if EVERYONE has Test.dxl loaded in the root of their C drive. Since its probably only on YOUR C drive, your code that sets the trigger should probably read the file into a variable and put the variable in the trigger call. string TriggerCode = readFile("c:/Test.dxl").

[] Your trigger code probably wants a check for Visible and link module status; if (isVisible(mCurr)) halt; if (type(module(fullName(mCurr))) != "Formal") halt.


- Louie
Report this to a Moderator Report this to a Moderator
 26-Mar-2007 11:21
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

Answer Answer
Hi Louie,

Don't want to be the wisenheimer,
but I've added some comments to your statements

quote:

Originally posted by: Louie Landale
Have read the thread. I haven't tested recently, but this is what I recall:


[] I don't think you can get the 'Module' handle of a module that's not yet open; which will happen for PRE module open triggers. POST open module triggers work OK; Module mCurr = current should do it.


Not yet the module handle, but the name of module to be opened with function
string module(Trigger)

I would suggest to never use current module handle within trigger code, because it may not give you everytime the module you want to process! It may work for module open triggers (not sure if it really does in any circumstances ), but for other trigger types it can be really confusing. There could be some error messages about not defined attributes or something else which not concerns the module you think the trigger should work on.

quote:


[] The 'module' of a trigger, IIRC, is the module that houses the trigger and not the one being fired. In your case you've put the trigger in the database and its not stored in a module.


That's not correct. The function will return the current version of module that fires the trigger or if not available null.
To get the storage point of trigger you may use
string stored(Trigger)
BTW: To get the (baselined) version of triggering module you need to add a second paramter to module function:
Module module (Trigger, int)
This second parameter should be 0, as described in DXL reference manual.

quote:


[] Your include statement will only work if EVERYONE has Test.dxl loaded in the root of their C drive. Since its probably only on YOUR C drive, your code that sets the trigger should probably read the file into a variable and put the variable in the trigger call. string TriggerCode = readFile("c:/Test.dxl").


Good idea!

quote:


[] Your trigger code probably wants a check for Visible and link module status; if (isVisible(mCurr)) halt; if (type(module(fullName(mCurr))) != "Formal") halt.


Really good hint. Would suggest to check for correct module version sometimes to.



quote:


- Louie


Greetings
Reik

-------------------------
Evosoft GmbH
for Siemens Industry Sector


Berlin, Germany
Report this to a Moderator Report this to a Moderator
 28-Mar-2007 22:35
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

[1] You've found a case that inside a trigger that requires an open module (post-open, pre-close, object, attr), that mod = current doesn't correctly return the module under consideration by the trigger? In normal DXL operation, I've NEVER had a problem with mod = current() to figure out the context of the DXL (although I have had some problem after the DXL is runing and has been opening modules...).

[2] I think I see the difference. I've written two scripts, one that reports triggers and one that finds them and offers to delete them. Both scripts have various "for trigger in whatever do" loops. Notice the triggers themselves are NOT firing. For such "Trigger" handles, the module(trg) function(s) return where its stored; usually null since such module-open triggers are generally in the Project or the Database. That's different from your experience that no doubt deals with 'Triggers' only once they are fired, Trig = current; Module = module(Trig); in which case the documentation and your observations are correct; module(trig) returns the module that's fired by the Trigger even when its stored elsewhere.

I do recall the nightmare I had figuring out how all this Trigger stuff works, when we were using v5.2. I specifically recall banging my head against the wall writing the library function that determines where a trigger is stored, the 'stored' command returning only an unqualified string; as did the string module(trg) command.

Anyway, its all hopelessly complicated. I did finally finish a "Report all the triggers in the database' script as well as the generic 'Find then offer to delete" triggers script, although the info they dumped was sometimes incomplete. Hard to believe Telelogic still had no GUI for Triggers. I've been thinking about creating one; allowing folks to define and deploy as well as search and delete.

What we really need is a mechanism in DXL to turn firing of triggers on and off, perhaps available only to admins. Relying on the command line switch -T isn't adequate.

- Louie
Report this to a Moderator Report this to a Moderator
 30-Mar-2007 10:13
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

Hi Louie,

quote:

Originally posted by: Louie Landale
[1] You've found a case that inside a trigger ...

Yes, I remember there was a problem in past, but I do not remember what caused it. May be in combination of different triggers, ADXL and LDXL which will open some more modules ...

quote:

[2] I think I see the difference. ...

I think you are right. There is a difference between usage of these functions inside and outside the running trigger.

quote:

I do recall the nightmare I had figuring out how all this Trigger stuff works...

Here are some bloody spots on the wall too

quote:

Anyway, its all hopelessly complicated.

You are sooo right ...
Really hard to find are errors which are not reported -> Try to create a module save trigger, no error, but does the same as winword.exe /u

quote:

What we really need is a mechanism in DXL to turn firing of triggers on and off...

That would be very usefull. The only ways you have now is to use some global variables or revove and insert the trigger
Do you really think that Telelogic will implement it - hope springs eternal

Greetings
Reik

-------------------------
Evosoft GmbH
for Siemens Industry Sector


Berlin, Germany
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.