comparing two columns of text

I have a DOORS module with object text in the main column and I have object text (layout DXL) in another column that was pulled in from another module using links. I want to compare these two columns of text and identify the differences between them. How can I accomplish this?
kottkl - Thu Aug 23 17:44:10 EDT 2012

Re: comparing two columns of text
SystemAdmin - Thu Aug 23 20:44:36 EDT 2012

The code below will hopefully give you a start.

This was created using the Analysis Wizard to create a DXL Layout column that displays the Object Text of objects at the other end of incoming links - I have identified where additional DXL code has been added to perform the comparison and display the result.



// DXL generated by DOORS traceability wizard on 24 August 2012. 
// Wizard version 2.0, DOORS version 9.2.0.3 pragma runLim, 0 

void showIn(Object o, 

int depth) 
{ Link l LinkRef lr ModName_ otherMod = 

null Module linkMod = 

null ModuleVersion otherVersion = 

null Object othero string disp = 

null string s = 

null string z = 

null   
//Added some buffers here Buffer otherObj = create    
//Buffer that will store the "Object Text" of the linked object in plain old text format  Buffer thisObj = create      
//Buffer that will store the "Object Text" of the corrent object in plain old text format  Buffer diffResult = create  
//Buffer that store the result of the DXK diff function   string plain, plainDisp 

int plainTextLen 

int count bool doneOne = 

false string linkModName = 
"*" 

for lr in all(o<-linkModName) 

do 
{ otherMod = module (sourceVersion lr) 

if (!

null otherMod) 
{ 

if ((!isDeleted otherMod) && (

null data(sourceVersion lr))) 
{ load((sourceVersion lr),

false) 
} 
} 
} 

for l in all(o<-linkModName) 

do 
{ otherVersion = sourceVersion l otherMod = module(otherVersion) 

if (

null otherMod || isDeleted otherMod) 

continue othero = source l 

if (

null othero) 
{ load(otherVersion,

false) 
} othero = source l 

if (

null othero) 

continue 

if (isDeleted othero) 

continue doneOne = 

true 

if (depth == 1) 
{ disp = 
"" s = probeAttr_(othero,
"Object Text") otherObj = s thisObj = obj.
"Object Text"     
//Added this block of code 
//Instead of just displaying Object Text from other link, added DXL code here to create and display marked up text difference  diff(diffResult, otherObj, thisObj,
"\\cf1\\strike ",
"\\cf3\\ul ") font(getCanvas, level(obj), HeadingsFont) displayRichWithColor(stringOf(diffResult)) delete otherObj delete thisObj delete diffResult   
} 
} 
} showIn(obj,1)


Paul Miller,
Melbourne, Australia

Re: comparing two columns of text
llandale - Fri Aug 24 09:32:26 EDT 2012

Paul's solution is better than what you asked for; although I presume there needs to be a check, allowing comparison only for links in a certain link module.

Here is some code that may get you going on what you asked for.

Buffer bufThis = create(), bufOther = create(), bufResults = create() Column col string ColTitle 

for col in (current Module) 

do 
{  ColTitle = title(col) 

if (ColTitle == 
"TheTitleIWant") 
{  bufOther = text(col) bufThis  = obj.
"Object Text" 
// use Paul's diff/canvas stuff here 

break 
} 
} delete(bufThis) delete(bufOther) delete(bufResults)


-Louie

Re: comparing two columns of text
JWiseman - Fri Aug 24 10:25:53 EDT 2012

The DXL Examples that are installed with the DOORS client contain a script that I have frequently used for this purpose. From the Tools->Edit DXL... menu select Browse... and look in the folder containing example programs. There is a script there labled "Example to create layout DXL column that shows changes to Object Text". It has a couple of modes of operation so you'll need to read the description that is embedded in it.

Note that since this tool was designed primarily for being able to track changes to a given module, you will need to instantiate the text coming in from your links. I.e., This script can't use the results of another DXL layout column. That means you will either have to setup your Layout DXL as DXL Attributes, or modify the script itself to walk the links. I use the former as I'm a bit weak in DXL scripting.

One last thing. There appears to be a bug in the version of that script that we have (came with the DOORS 9.3.0.5 client). one of the advanced settings allowing customization of the appearance of the output doesn't work (I forget which) but the default output was acceptable for us.

Hope this helps!