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 object attributes with richTextWithOle
Topic Summary:
Created On: 25-Aug-2004 12:50
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.
 25-Aug-2004 12:50
User is offline View Users Profile Print this message


Richard Brecknell

Posts: 8
Joined: 25-Aug-2004

Hi,

I am fairly new to this DXL lark, so there may be an easier way to do what I am trying to do, but the way I am trying to do it now is presenting a major problem.

I am trying to compare two objects from different baselines of the same module. If the objects are different I copy them into a new module. I have written the following bit of code:

bool res=true
string attrName
for attrName in comparisonAttributes do {
string s1 = richTextWithOle o1.attrName
string s2 = richTextWithOle o2.attrName
if(s1 != s2) {
res = false
}
}
return res


There are lost of attributes that have been introduced into the model and more than one of them is rich text type. There could also be multiple Oles in a particular attribute.

This approach works fine, except that it soon grabs all the memory available, then all the swap space until no memory is left. This comparison is a small part of a larger program, but I have narrowed it down to the two calls to richTextWithOle. As they are held within a for loop, I was expecting the dxl to free the memory from s1 and s2 each time, but this does not seem to be happening. Is there some way to force the memory to be freed, or another way to compare the objects? (It is possible that the objects have different attributes, as they are from different baselines, that is why I loop through the attributes I have found to be common).

I thought about using buffers, but I still need to make the call to richTextWithOle to get the string to put in the buffer, so I don't think that would help.

I am using DOORS 6

Thanks for any ideas.
Report this to a Moderator Report this to a Moderator
 25-Aug-2004 13:01
User is offline View Users Profile Print this message


Paul Tiplady

Posts: 176
Joined: 28-Oct-2003

DXL is really not very good with memory. It could well be that, because you are declaring the two strings inside the loop, memory is being reserved (incrementally) on each pass through the loop. Try declaring them outside the loop, and see if it helps.

Buffers would help, but again you'd want to declare them outside your loop. Probably...

Aside If the above is true, it kind of implies we should be doing everything with global variables to conserve memory. Ouch!


-------------------------


Paul dot Tiplady at TRW dot com
TRW Automotive

Edited: 25-Aug-2004 at 13:06 by Paul Tiplady
Report this to a Moderator Report this to a Moderator
 25-Aug-2004 14:36
User is offline View Users Profile Print this message


Tony Goodman

Posts: 1098
Joined: 12-Sep-2002

Buffers are best really. You could try using the following to convert buffers to strings for the comparison:

string tempStringOf(Buffer b)

This creates a (very) temporary string that does not persist in the string table.


-------------------------
Tony Goodman
http://www.smartdxl.com
Report this to a Moderator Report this to a Moderator
 25-Aug-2004 14:58
User is offline View Users Profile Print this message


Richard Brecknell

Posts: 8
Joined: 25-Aug-2004

Making the strings global did not help. As the program run, the memory still ramped up until it was all gone.

The memory was not free when the program ended or the modules were shut down. It only freed its memory, when DOORS was closed.

Using buffers instead worked fine. I now create 2 buffers before the for loop, set them and compare them directly, i.e.

Buffer b1=create
Buffer b2=create
for ... do {
b1=richTextWithOle o1.attrName
b2=richTextWithOle o2.attrName
if(b1 != b2) {
res=false
}
}
delete b1
delete b2

it appears that I do not need to create temporary strings for the compare.
Report this to a Moderator Report this to a Moderator
 1-Sep-2004 09:39
User is offline View Users Profile Print this message


Richard Brecknell

Posts: 8
Joined: 25-Aug-2004

Actually now I look into it more closely, using buffers has made no difference what so ever. It appeared that I was not leaking memory any more, but this was due to a bug I introduced that stopped it comparing the oles for a different reason.

As far as I can see, there seems to be no way to identify if an ole within an object has changed, without leaking memory the same size as the ole! I have sent the telelogic support a mail asking for their assistance.
Report this to a Moderator Report this to a Moderator
 3-Sep-2004 16:22
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

I had this problem and discovered this unfortunate reality: if you get the richTextWithOle and then set it to an new object, then retrieve the richTextWithOle from the new and compare it to the old, it is NOT the same. That is:

Text1 = richTextWithOle(o1."Object Text")
o2."Object Text" = Text1
Text2 = richTextWithOle(o2."Object Text")
if (Text1 !=Text2) then Louie is rignt; so long as o1 contains OLE diagrams.

It appears the "OLE" portion of the rich text contains plenty of "empty" space that gets filled with whatever happens to be in that empty window when you retrieve the text. I hate it when that happens.

I had some luck plowing through the richText extracting each ole, sending it to a file, then comparing the two files. I think that worked since saving the OLE to a file seems to drastically reduce its size, elliminating the empty windows therein. Yuuuuck, and it didn't save much time. What I ended up doing was this:

Compare the two Texts using "richTextNoOle".
If they are the same then compare the two object's Last Modified On dates.
If they are the same then presume there are no changes to the embedded OLE diagrams
otherwise go ahead and waste a lot of time an memory copying the richTextWithOle texts.

Another option would be to plow through the History of the source object, looking for "Modify Object" history applying to Object Text.

I don't recall if I had any luck getting the LENGTHS of the richTextWithOLE, figuring if the lengths of these were the same (e.g. 875,344 bytes) and the richTextNoOle were the same, then they must be the same. I have a nagging memory that it didn't work (length(Text2) != length(Text1) above.

Good luck.

- Louie
Report this to a Moderator Report this to a Moderator
 17-Oct-2006 14:10
User is offline View Users Profile Print this message


Chris Annal

Posts: 36
Joined: 14-Dec-2005

Was there a suggested script posted elsewhere for the possible solution? I tried to hack out a script that compares the Object Text, as suggested, but I'm really struggling with the "Last Modified On" attribute comparison. One of my users wants to format his VRTM so that if a requirement was tested in multiple events, only the last event is included in his VRTM. This corresponds to the "Last Modified On" value, but I'm having no luck putting it all together.
Here's what I had, so far:

string Attr = "Object Text"
Object obj1 = current
Object obj2 = next obj1
//Object obj3 (thought I'd need this for storing the result of "last mod compare")
Date LastMod = "Last Modified On"
int countOLE1 = oleCount(obj1.Attr)
int countOLE2 = oleCount(obj2.Attr)
Buffer ole1 = create()
Buffer ole2 = create()

//*******************************************

if (countOLE1 == 0)
ole1 += richTextFragment richTextNoOle obj1.Attr
else
ole1 += richTextWithOle obj1.Attr

if (countOLE2 == 0)
ole2 += richTextFragment richTextNoOle obj2.Attr
else
ole2 += richTextWithOle obj2.Attr

if (ole1 != ole2)
{
 display obj1.Attr
}       
else if (intOf(obj1.LastMod) < intOf(obj2.LastMod)) //DXL complains about using dot format here
print intOf(obj1.LastMod)
{
 display obj2.Attr
}              
else
 print "Wassup??" // code never gets this far

delete ole1
delete ole2

Report this to a Moderator Report this to a Moderator
 17-Oct-2006 14:26
User is offline View Users Profile Print this message


Paul Tiplady

Posts: 176
Joined: 28-Oct-2003

Your code has a flaw, around the 'else' for the 'if (ole1 != ole2)'. The only statement in the else is the if, and the only statement in the if is the print. the '{ display obj2.Attr }' is back at the outer level of code, and the else after is it meaningless. The line you comment with 'code never gets this far' cannot be exeuted. I think you meant to put the 'if(intOf(...' bit inside the curly brackets for the else, like the snippet below...

Other than that, I have no idea...

-------------------------


Paul dot Tiplady at TRW dot com
TRW Automotive

Edited: 17-Oct-2006 at 14:27 by Paul Tiplady
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.