![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Text attributes the same Topic Summary: Created On: 19-May-2005 17:40 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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
|
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Text attributes the same
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.