PDA

View Full Version : Comparing folders, want to write some special Rules


ask_j
07-Sep-2010, 08:27 PM
Hi,
I have a requirement where we read entire database and create text files called .kbs files. Whenever we change the generator we have to generate and compare files generated by old vs new generator. My current issue is that I am using vendor API in the old generator which is not producing consistent result, meaning sometimes more white spaces, sometimes some lines has CxMExp and other times it has CxExp etc. But both works when files loaded on the server. There are many more issues for which I am able to write rules etc. For example I am able to ignore the entire line if a particular text found etc.

I read lot of posts to ignore white spaces and I created a new file format and created few rules to ignore certain lines. My question is how can I ignore the difference between CxMExp and CxExp? I tried creating a Basic rule as RegEx, saying anything matching Cx*Exp should be ignored. Its not working (I unchecked the box when running using rules).

Also I am facing two more issues. First one is that there are some lines which are coming in different order. Meaning for example I want to write a rule saying if a line starts with "Import" and other characters in the line are present at some other line number in the second file then ignore this difference.
for example file 1
<Import abc=dbc1.txt>
<Import abc=dbc2.txt>
<Import abc=dbc3.txt>
<Import abc=dbc4.txt>
<Parameter ab [1,3,4,5] >
<Parameter db [5,4,6,8] >

file 2
<Import abc=dbc1.txt>
<Import abc=dbc4.txt>
<Import abc=dbc2.txt>
<Import abc=dbc3.txt>
<Parameter ab [1,3,4,5] >
<Parameter db [5,4,6,8] >

So in this example I want to say that file 1 and 2 are equal

Secondly I want to state a rule to compare following two files and still want them equal. Both the files can contain more that these kind of situations and also many other lines with matching/un-matching characters.

file 1
<com "abc" "model" "abc" [id="1", name="t1", dec="help wanted", seqNo="100"] >

file 2
<com "abc" "model" "abc" [dec="help wanted", name="t1", id="1", seqNo="100"] >


Please help..

Aaron
17-Sep-2010, 03:25 PM
Hello,

For part 1, you will want to reference this article:
http://www.scootersoftware.com/support.php?zz=kb_unimportantv3
These steps should help you define a text based grammar rule that will show "Cx.Exp" as Blue, and then be hidden by toggling on Ignore Unimportant Differences.
If you are still having trouble with this step, please email us your Support.zip from the Help menu -> Support; Export, and a pair of sample files that you are using. We can then see what you are currently working with and help you alter your grammar rules.

For part 2, you will want to reference this article:
http://www.scootersoftware.com/support.php?zz=kb_externalconversion
Moved lines are considered important. The way we deal with them in BC3 is to perform an external conversion that can sort your files. We have a built-in method called "Sort" that will sort the entire file line by line, or you can create your own command line application and call it from within BC3.

For part 3, you will want to follow the same directions as part 2. Sorting within a line is another step that would need to be done. We have an example of this in the XML Tidied with Sorted Attributes, which sorts the way you expect for standard XML structure.
http://www.scootersoftware.com/download.php?zz=kb_moreformats
Unfortunately, your files do not appear to be standard XML, so you would need a custom solution to sort that data, or mark the entire section as Unimportant.