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: Comparing Current to baseline modules
Topic Summary: Comparing all modules current vs latest baseline
Created On: 28-Jun-2006 18:37
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 Louie Landale, on Tuesday, August 29, 2006 6:12 PM

Answer:
Briefly looked at the script. The for module... loops are pretty weak and all have restrictions. the for NameMod in Project loop only finds modules in the project's root folder; other loops only finds currently open modules. You should routinely use the "for item in whatever" loops, then look at the type of item, in this case:

Item itm
for itm in (current Project) do
{ if (type(itm) != "Formal") continue
string NameModFull = fullName(itm)
Module mod = read(NameModFull, false)
deal with module...
close(mod)
} // end for items in Project

- Louie
 28-Jun-2006 18:37
User is offline View Users Profile Print this message


Donald Bowles

Posts: 6
Joined: 4-Dec-2003

I want the following dxl to automatically select the current and latest baseline, make a comparison, close the module and then continue on to the next module in the current project. I could really use some help.
Thanks
Stream file = write ("C:/compare.doc")
string modName
for modName in current Project do {
if (type module modName == "Formal") {
if (!open module modName) then {
read (modName, false)
file << modName "\n"
DBE list1, list2 // two global lists containing the baseline
// selected (or current version)

Skip baselines = create // cache current baselines


// function to compare an attribute of two objects with
// same absolute number
//
bool compare(int absno, Object o1, o2, string attr) {

string s1, s2

s1 = o1.attr
s2 = o2.attr

if (s1!=s2) {
file << "object #" absno " has differing " attr "\n New Text\t" s1 "\n Old Text\t" s2 "\n""\n"
accept o1 // set filter
accept o2 // on both objects
return false
}
return true
}

// Build a skip list which maps absnos onto their corresponding
// objects. Also initialize the DXL filter to "reject"
//
Skip getAbsnos(Module m) {
Skip res = create

Object o
for o in m do {
int a = o."Absolute Number"
reject o // filter those mentioned in report
put(res, a, o)
}
return res
}

// Main comparison routine:
// find out which modules to compare
// compare objects present in both, report on
// those present in only one.
//
//
void compareFn (DBE dbe) {
string name1, name2
int idx1, idx2

idx1 = get list1 // position in list
idx2 = get list2

name1 = get list1 // baseline name
name2 = get list2

if (idx1 < 0 || idx2 < 0) { // error checking
ack "two selections are needed"
return
} else if (idx1 == idx2) {
ack "same selection on both sides"
return
}

Baseline sel1, sel2

string str

for str in baselines do { // find each baseline

Baseline b = key baselines // the baseline is the key

string str = (major b) "." (minor b) (suffix b)

if (name1==str) sel1 = b

if (name2==str) sel2 = b
}

Module old = current
Module b1, b2

if (idx1==0) b1 = old // i.e. the current Module
else
b1 = load(sel1, true) // load the baselines on the screen

if (idx2==0) b2 = old // i.e.e teh current Module
else
b2 = load(sel2, true)

current = b1 // make sure filtering is off
filtering off // on both sides.
current = b2
filtering off
current = old

Skip absno1 = getAbsnos b1 // build caches of absnos -> objects
Skip absno2 = getAbsnos b2

Object o1, o2
int diffs = 0

for o1 in absno1 do { // loop through side 1
Object o2
int i = (int key absno1)

if (find(absno2, i, o2)) { // absno exists in other baseline

// compare attributes -- easy to add more tests!

if (!compare(i, o1, o2, "Object Heading") ||
!compare(i, o1, o2, "Object Text"))
diffs++ // found a difference

delete(absno2, i) // remove from list2

} else {
file << "object #" i " only exists in " name1 "\n"
accept o1
diffs++
}
}

for o2 in absno2 do { // now we can check for
// objects not in list1
int i = (int key absno2)
file << "object #" i " only exists in " name2 "\n"
accept o2
diffs++
}

delete absno1 // delete caches
delete absno2

bool doFilter // set to true if differences

if (diffs==0) {
file << "no differences found\n"
doFilter=false
} else { // set filtering on in baselines

if (diffs==1)
file << "one difference found\n"
else
file << diffs " differences found\n"

doFilter=true
}

current = b1 // set filters
filtering doFilter
refresh current
current = b2
filtering doFilter
refresh current
current = old // return to former current module
}

//// MAIN PROGRAM ////////////////////////

Module m = current // check calling context

if (null m) {
ack "program requires current Module"
halt
}

// count number of baselines

Baseline b
int i=0

for b in m do {
i++
}


if (i==0) {
ack "no baselines to compare"
continue
}

// Now make a dialog for selecting two baselines for
// comparison

string where = (current Module)."Name"

DB db = create "Baseline Compare \"" where "\""
string empty[] = {}

list1 = list(db, "", 300, i+1 <? 5, empty) // make maximum size of 5 elements
list2 = list(db, "", 300, i+1 <? 5, empty)

list1->"right"->"unattached" // make lists side by side
list2->"left"->"flush"->list1
list2->"top"->"aligned"->list1
list2->"right"->"unattached"

button(db, "Compare", compareFn)

realize db // we realize so that the
// lists can be populated
// using insert

// fill up the baselines skip list with current baselines

for b in m do {
string str = (major b) "." (minor b) (suffix b)
put(baselines, b, str)
insert(list1, 0, str)
insert(list2, 0, str)
}

insert(list1, 0, "current") // put current at head of lists
insert(list2, 0, "current")

show db // off we go.......
print "Complete"
}
}
}

-------------------------
Don Bowles
Report this to a Moderator Report this to a Moderator
 29-Jun-2006 13:19
User is offline View Users Profile Print this message


Tony Goodman

Posts: 1098
Joined: 12-Sep-2002

If you just want to compare the current version with the latest baseline, then you don't need to mess around loading baselines, just look at the history in the current version.

The following is a hastily hacked example to do what you are after.

The script simply opens every formal module in the current project and prints the history records to a file.

Hope this helps you to get started.

-------------------------
Tony Goodman
http://www.smartdxl.com
Report this to a Moderator Report this to a Moderator
 29-Jun-2006 22:50
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Answer Answer
Briefly looked at the script. The for module... loops are pretty weak and all have restrictions. the for NameMod in Project loop only finds modules in the project's root folder; other loops only finds currently open modules. You should routinely use the "for item in whatever" loops, then look at the type of item, in this case:

Item itm
for itm in (current Project) do
{ if (type(itm) != "Formal") continue
string NameModFull = fullName(itm)
Module mod = read(NameModFull, false)
deal with module...
close(mod)
} // end for items in Project

- Louie
Report this to a Moderator Report this to a Moderator
 8-Aug-2006 13:39
User is offline View Users Profile Print this message


Donald Bowles

Posts: 6
Joined: 4-Dec-2003

Thanks,
I have been sick for awhile. Will try it out.
Don Bowles

-------------------------
Don Bowles
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.