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: Text attributes the same
Topic Summary:
Created On: 19-May-2005 17:40
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.
 19-May-2005 17:40
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

I'm having trouble writing a function that determines if two text attributes are the same. I need to figure out if differences in RichText markup substancially change the text, or if the differences are just cosmetic. I think I cannot determine if the content of an OLE diagram is the same. Some things I've been playing with are [1] is the raw text of each identical [2] is the length of the rich text the same [3] is the number of OLE diagrams the same.

What I think I need is some function that will standardize the RichText markup, so I can then compare them exactly. The richTextFragment command seems to strip OLE diagrams, and causes exponetial script slow-down, making it useless for some of my big long running scripts.

Any ideas?

- Louie
Report this to a Moderator Report this to a Moderator
 20-May-2005 07:03
User is offline View Users Profile Print this message


Dave Robbins

Posts: 36
Joined: 9-Dec-2003

Louie, have a look at the attached layout DXL which we use as part of our Change Management process, so that reviewers can assess the changes.

change 'My Attribute' at the bottom to specify the atttibutes to diff.



// DXL to diff two strings/Attributes with indication of amount of change via an int


/*
AUTHOR: Dave Robbins

DATE: 25/11/04


Known issues/limitations:

** Uses new V7 'displayRichWithColor' function so won't work on pre-V7 Modules


The script is not able to:



*/

/*************************************************************************
CHANGES
**************************************************************************
VERSION AUTHOR DATE DESCRIPTION/REASON
0.1 DIR 25/11/04 First issue

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



// includes


// functions

////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
string diffString( string &resultS, int &percentageDiff, string sourceS, targetS ) {

percentageDiff = 0 // no change
int origLength, resultLength
string returnS = "", plainTextOriginal, plainTextResult
Buffer originalText = create()
Buffer newText = create()
Buffer resultText = create()

//if(null targetS) targetS = ""

originalText = sourceS
newText = targetS

returnS = diff(resultText, originalText, newText, "\\cf1\\strike ", "\\cf3\\ul ") ""


// get just the plain ASCII so we can see if there is an identified difference
plainTextOriginal = plainText sourceS
plainTextResult = plainText( stringOf resultText )

origLength = length(plainTextOriginal)
resultLength = length(plainTextResult)

if( resultLength != origLength ) {
// looks like the source and target are different, therfore return the result...
resultS = stringOf(resultText)
percentageDiff = ((1000 * origLength / resultLength) + 5) / 10 // rough indication of the change, rounded up
}

return returnS // result only valid if non-null string is returned
delete originalText
delete newText
delete resultText

} // end diffAttribute
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////


// layout DXL setup

//Object obj = current
string diffS = ""
int percent = 0

//Text
diffString( diffS, percent, probeAttr_(obj,"My Attribute1"), probeAttr_(obj,"My Attribute2") )
displayRichWithColor diffS // V7.1 fn only

-------------------------
Dave
+44 (0)23 9270 5711
david.robbins@astrium.eads.net
~~~~~~~~~~~~~~~~~~~~
EADS Astrium, Anchorage Road
Portsmouth. Hampshire. UK PO3 5PU
Report this to a Moderator Report this to a Moderator
 20-May-2005 16:12
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

You've got a "plainText(string TextRich)" function?

Yes, I know about comparing the raw text. Your function works when the raw text is the same. But whatabout rich strings, for instance one that says "that" and the other that says "that" but is italicized? And I'm sure it falls apart when the Text has OLE diagrams.

I once played around with the notion of saving each OLE to a temporary file, then reading the files to insure they were the same. I don't recall for sure, but I think that failed since identical OLEs get saved differently to different files.

- Louie
Report this to a Moderator Report this to a Moderator
 25-May-2005 23:15
User is offline View Users Profile Print this message


Hung Tran

Posts: 3
Joined: 24-May-2005

Louie, I read your repply on the Topic Title: "comparing object attributes with richTextWithOle". You had mention about the comparing .png files after saving each OLE to a temporary file. Could you show me how to compare these .png files? Thanks, Hung Tran
Report this to a Moderator Report this to a Moderator
 26-May-2005 17:44
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

I found a two year old program that trys to figure out if two object attributes are the same, and specifically if two embedded OLE diagrams was the same (exporting to a file and comparing the files). The main purpose of the script was to save time copying object values: if they are the same don't bother copying and save time.

Anyway, I don't recall what I found out but there is a section on text results.

Its too big for the forum. If you send me your Email I promise not to tell anyone and I'll send the DXL (14kb). The file compare part seemed to work, but wasn't worth the effort.

- Louie
Report this to a Moderator Report this to a Moderator
 27-May-2005 19:37
User is offline View Users Profile Print this message


Hung Tran

Posts: 3
Joined: 24-May-2005

Louie,

Try this one. Hopefully it help.

//Compare Object Text on current and next object include OLE embedded.

string Attr = "Object Text"
Object obj1 = current
Object obj2 = next obj1

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)
print "diff"
else
print "same"

delete ole1
delele ole2


Edited: 1-Jun-2005 at 14:23 by Hung Tran
Report this to a Moderator Report this to a Moderator
 31-May-2005 20:55
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

If you put an Ole in obj1.Attr, then issue obj2.Attr = richTextWithOle(obj1, Attr), and then run your script, I think you'll find the result is "diff". Attr 2 may have the same apparent value but the details are different.

My current algoritm is [] are the counts of OLEs the same [] are the raw texts identical [] do the full texts have the same length.

- Louie
Report this to a Moderator Report this to a Moderator
 1-Jun-2005 14:21
User is offline View Users Profile Print this message


Hung Tran

Posts: 3
Joined: 24-May-2005

Louie,

The result is still the "same"

string Attr = "Object Text"
Object obj1 = current
Object obj2 = next obj1

obj2.Attr = richTextWithOle obj1.Attr

if (obj1.Attr "" != obj2.Attr "")
print "diff"
else
print "same"

Edited: 1-Jun-2005 at 14:21 by Hung Tran
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.