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: Demote/promote objects using DXL
Topic Summary:
Created On: 27-Feb-2008 13:51
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.
 27-Feb-2008 13:51
User is offline View Users Profile Print this message


Nikkia Carter

Posts: 18
Joined: 26-Feb-2008

Hey! Does anybody know the code in DXL which will have the same effect on objects as the demote and promote buttons have in the DOORS window? I tried to use move (o2, below o1) but it is not doing what the button does.

Peace and Blessings,
Nikkia Carter
Report this to a Moderator Report this to a Moderator
 27-Feb-2008 14:30
User is offline View Users Profile Print this message


Scott Boisvert

Posts: 348
Joined: 14-Apr-2006

Use the following:

callStdItem_ (objPromoteItem)
callStdItem_ (objDemoteItem)

-------------------------
Scott Boisvert
Engineering Tools Administrator
L-3 Communications - Avionics Systems
scott.boisvert@l-3com.com
Report this to a Moderator Report this to a Moderator
 27-Feb-2008 16:04
User is offline View Users Profile Print this message


Lee Farmer

Posts: 9
Joined: 12-Apr-2005

Scott,

This is Nikkia. I'm using my boss's account. Thanks so much for your response. Could you explain how to use this function or where to find additional info on it? I tried it out but keep getting an invalid argument error. I replaced objDemoteItem with lvl2obj which is a object.

Peace and Blessings,
Nikkia Carter
Report this to a Moderator Report this to a Moderator
 27-Feb-2008 16:15
User is offline View Users Profile Print this message


Scott Boisvert

Posts: 348
Joined: 14-Apr-2006

Hi Nikkia,

objPromoteItem and objDemoteItem are not variables to be replaced, these are the actual function calls that the "Promote Object" and "Demote Object" buttons use to promote or demote an object. These function calls are what can be called a DOORS Standard Item, basically a method declared at startup. To call these methods you need to use the callStdItem_ () method.

An example of how to use:

- Select the object you wish to promote.
- Open the DXL editor.
- Enter callStdItem_ (objPromoteItem) in the DXL editor.
- Click the Run button.

The selected object should be promted as it would if you clicked on the Promote Object button.

The callStdItem_ is an undocumented function I believe. Basically it will call any of the predefined methods that Telelogic has defined. You can find alot of these predefined/standard items in the formal.dxl file.

-------------------------
Scott Boisvert
Engineering Tools Administrator
L-3 Communications - Avionics Systems
scott.boisvert@l-3com.com

Edited: 27-Feb-2008 at 16:19 by Scott Boisvert
Report this to a Moderator Report this to a Moderator
 27-Feb-2008 16:47
User is offline View Users Profile Print this message


Lee Farmer

Posts: 9
Joined: 12-Apr-2005

Scott,

Thanks!

I used it and now get the following error "Standard menu item objDemoteItem is unavailable". I noticed that the demote button is also unselectable. I am running my script on a module, trying to automate demoting objects per hierarchy number. I am running the script while in Exclusive Edit mode. Is there a way to keep that item available?

Object o;

for o in current Module do
{

}

Peace and blessings,
Nikkia Carter
Report this to a Moderator Report this to a Moderator
 27-Feb-2008 16:51
User is offline View Users Profile Print this message


Lee Farmer

Posts: 9
Joined: 12-Apr-2005

Scott,

I got cut off before I could complete the code:
_____________________________________________
Object o;

for o in current Module do
{
o = current;
if(o."Hierarchy" "" == "1")
{
o = next o;
}
if(o."Hierarchy" "" == "2")
{
callStdItem_(objDemoteItem);
}
}
_______________________________________________

Hierarchy is only 1 and 2.
Report this to a Moderator Report this to a Moderator
 27-Feb-2008 16:52
User is offline View Users Profile Print this message


Scott Boisvert

Posts: 348
Joined: 14-Apr-2006

Try adding the following line prior to promoting or demoting:

current = o

The objDemoteItem and objPromoteItem need a current object that is able to be promoted or demoted. For intance you wouldn't be able to promote an object that is all ready at level 1. So you may want to check the level of the object before you promote or demote as well.

-------------------------
Scott Boisvert
Engineering Tools Administrator
L-3 Communications - Avionics Systems
scott.boisvert@l-3com.com
Report this to a Moderator Report this to a Moderator
 27-Feb-2008 17:04
User is offline View Users Profile Print this message


Scott Boisvert

Posts: 348
Joined: 14-Apr-2006

Originally posted by: Lee Farmer

Scott,



I got cut off before I could complete the code:

_____________________________________________

Object o;



for o in current Module do

{

o = current;

if(o."Hierarchy" "" == "1")

{

o = next o;

}

if(o."Hierarchy" "" == "2")

{

callStdItem_(objDemoteItem);

}

}

_______________________________________________



Hierarchy is only 1 and 2.


Hmm....

Haven't really played with promoting and demoting much, but here goes. From what I can tell to demote an object it must have an object above it that can be made a child of. So for instance:

- Object 1
-- Object 2
-- Object 3

You wouldn't be able to demote Object 2 because there is no object above it to make it a child of. However, you could demote Object 3. You may need to put some extra checks in the script to account for this behavior. It appears that your script is tryting to take the above structure and do turn it into this structure

- Object 1
--- Object 2
--- Object 3

which isn't going to be possible as the objects at level 3 are going to need a parent object at level 2.

-------------------------
Scott Boisvert
Engineering Tools Administrator
L-3 Communications - Avionics Systems
scott.boisvert@l-3com.com
Report this to a Moderator Report this to a Moderator
 27-Feb-2008 17:14
User is offline View Users Profile Print this message


Lee Farmer

Posts: 9
Joined: 12-Apr-2005

Scott,

Well, it is actually more like turning this:
Obj1
Obj2
Obj2
Obj2
Obj2
Obj2
Obj1
Obj1
Obj2
Obj1
Obj2
Obj2
Obj2
Obj1

Into this:
Obj1
-Obj2
-Obj2
-Obj2
-Obj2
-Obj2
Obj1
Obj1
-Obj2
Obj1
-Obj2
-Obj2
-Obj2
Obj1

Have any ideas or is it a lost cause to automate?

Thank so much for your help!

Peace and Blessings,
Nikkia Carter
Report this to a Moderator Report this to a Moderator
 27-Feb-2008 17:34
User is offline View Users Profile Print this message


Scott Boisvert

Posts: 348
Joined: 14-Apr-2006

Check the current level of the objects in the module. Make sure that they are still all at level 1. I just added 10 new objects to a new module all at level 1 and I don't see why this wouldn't work.

Another question would be is if the "Hierarchy" attribute is actually a string/text attribute and not an integer attribute. If it's an integer I don't think you need the qoutes are around the 1 and 2.

Just noticed you have a o = next o if the Heirarchy = 1. You don't need that there, cause you'll skip over the next object.

The attached code seemed to work for me with everything at level 1 initially. Keep in mind I made my Hierarych attribute an integer type attribute so if yours is a string or text type you'll need the qoutes around the 1 and 2.

-------------------------
Scott Boisvert
Engineering Tools Administrator
L-3 Communications - Avionics Systems
scott.boisvert@l-3com.com
Report this to a Moderator Report this to a Moderator
 27-Feb-2008 18:47
User is offline View Users Profile Print this message


Nikkia Carter

Posts: 18
Joined: 26-Feb-2008

Scott,

Thank so much! Here is the end result:
___________________________________________
Object o;

for o in current Module do
{
if (null next o)
break;

if (!null next o)
{
o = next o;

if(o."Hierarchy" "" == "1")
{}

if(o."Hierarchy" "" == "2")
{
current = o;
callStdItem_(objDemoteItem);
}
}

I have to wait for my manager to approve but it seems that it does EXACTLY what I want it to do. Thanks again!!! You help has made all the difference! Thank soooooooo much!!!!

Peace and Blessings,
Nikkia Carter
_______________________________________________
Report this to a Moderator Report this to a Moderator
 27-Feb-2008 18:59
User is offline View Users Profile Print this message


Scott Boisvert

Posts: 348
Joined: 14-Apr-2006

Nikkia,

One thing I noticed is it looks as if you have some wasted code, though I could be wrong.

When using the "for o in current Module do" loop you don't need to tell DOORS to goto the next object, it does it automajically. Using this loop you should never see a null object unless you are at the last object and the module and you check if the next object is null (consequently at the first object and check the if the previous object is null).

the

if (null next o)
break;

if (null next o)
{
o = next o;
}

will be executed but I see no need for it. It will only cause you to exit out of the loop when you get the last object in the module, which the loop will do on its own. I personally don't see extra code causing problems with the script working properly, but you never know. I try to make it a rule to not use code that it isn't needed, just causes more maintenance down the road.

-------------------------
Scott Boisvert
Engineering Tools Administrator
L-3 Communications - Avionics Systems
scott.boisvert@l-3com.com
Report this to a Moderator Report this to a Moderator
 27-Feb-2008 19:24
User is offline View Users Profile Print this message


Nikkia Carter

Posts: 18
Joined: 26-Feb-2008

Scott,
Thanks! I am going to see if it is waste. I didn't have that in there before and the code was not behaving properly. It could have been caused by something else but I was just about to go back and get rid of deadwood if any and pretty it up. Thanks!

Peace and Blessings,
Nikkia Carter
Report this to a Moderator Report this to a Moderator
 27-Feb-2008 20:00
User is offline View Users Profile Print this message


Nikkia Carter

Posts: 18
Joined: 26-Feb-2008

Scott,

Got rid of the deadwood and it is all pretty now. Thanks so much again!

Peace and Blessings,
Nikkia Carter
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.