Specify alignment of 2 files according to rule?

General questions about using ExamDiff Pro, ideas for new features, bug reports, and usage tips.
arobustus
Junior Member
Posts: 13
Joined: Mon Aug 25, 2008 9:10 am

Specify alignment of 2 files according to rule?

Post by arobustus »

I would like to compel ExamDiff to align certain lines according to a rule. That is, if a pair of lines, one in one file, the other in another file, satisfied the rule, ExamDiff would make them line up on two sides of the screen, whatever else it did. The rule would be as follows: Lines starting with a capital M & followed by a three digit number between [lower limit] and [upper limit], having nothing else on the line, would line up. If one file had more such lines than the other did, it would just line up as many as possible. As such, it would be a tool for editing CNC programs for 2-channel machine controls. Can ExamDiff do anything like that?
Thanx,
-plh
User avatar
psguru
Site Admin
Posts: 2396
Joined: Sat May 15, 2004 4:23 pm
Location: California
Contact:

Re: Specify alignment of 2 files according to rule?

Post by psguru »

You can use "Ignore parts of each line ... matching a regular expression" option Under Options | Compare. If you need help in figuring our the regex, please post examples of your lines and their part that are to be ignored.
psguru
PrestoSoft
arobustus
Junior Member
Posts: 13
Joined: Mon Aug 25, 2008 9:10 am

Re: Specify alignment of 2 files according to rule?

Post by arobustus »

I am not trying to ignore anything. I tried various options but none did the trick.
I am trying to place the lines that follow the rule at a greater priority than others. A kind of uber match.
If this is not possible, another way of doing it would be to ignore everything except lines beginning with the capital M and having a three-digit number between 500 and 599 following the M and nothing else on the line.
In the ZIP file attached, you can see that it aligned M500 and M504, but from then on, it did not align what we would call the "wait codes".
Thank You,
-plh
Attachments
UberMatch.zip
(29.62 KiB) Downloaded 854 times
User avatar
psguru
Site Admin
Posts: 2396
Joined: Sat May 15, 2004 4:23 pm
Location: California
Contact:

Re: Specify alignment of 2 files according to rule?

Post by psguru »

Still trying to understand... What is the next (after M504) pair of lines that you'd want to match?
psguru
PrestoSoft
arobustus
Junior Member
Posts: 13
Joined: Mon Aug 25, 2008 9:10 am

Re: Specify alignment of 2 files according to rule?

Post by arobustus »

The rule would apply throughout. Lines that begin with the letter M followed by an integer between 500 and 599 would match.
The next match should have been with the line M506. This occurs at line 120 in each column. They would line up from side to side.
It turns out that lines 163 and 169, having M507 and M508 respectively, match.
M509 is skipped.
M510 occurs on 410. That matches.
M511 is skipped. M512 and M513 match.
The next "wait code" is M523 on line 850. That does not match.
M524 matches, as do all the other wait codes out to the end.
That I am really trying to do here is make Exam Diff act as a quick way to check this fundamental aspect of two-column machine tool programming. Each column controls a separate tool spindle of the machine. They are moving independently of each other in the same machine, so if these wait codes are not properly distributed, the result could be a catastrophic wreck. It could cost tens or even hundreds of thousands of dollars to fix, could take weeks, and the machine might never be the same.
In the case of the pair of programs in the ZIP file attached to my last post, the programmer added spaces so that if he copies and pastes them into Excel he can accomplish this. However, that involves the tedious and time-consuming maintenance of a large number of CrLfs that make it cumbersome to use text editor such as UltraEdit (my personal fave).
In the case of the file set attached to this post, all the extra ClCfs have been removed. The result was the same, skipping M506 and M523. I played with the colors so that only matched items get a changed background color. Ideally, all lines following the rule would match and only those would receive color.
Am I asking for too much?
Thank You,
-plh
Attachments
UberMatch2.zip
(20.46 KiB) Downloaded 870 times
User avatar
psguru
Site Admin
Posts: 2396
Joined: Sat May 15, 2004 4:23 pm
Location: California
Contact:

Re: Specify alignment of 2 files according to rule?

Post by psguru »

No, not too much. However the feature you are asking for doesn't exist in ExamDiff Pro. The only way to force alignment right now is manual. Have your tried manual linking of lines? I understand that it may be a tedious process in case of large files, but at least it will give you the results you are seeking.
psguru
PrestoSoft
arobustus
Junior Member
Posts: 13
Joined: Mon Aug 25, 2008 9:10 am

Re: Specify alignment of 2 files according to rule?

Post by arobustus »

I was just trying that and the problem is that when I edit the file in another window, say UltraEdit, then return to ExamDiff, if I have added lines to one side no the link(s) on that side are in the wrong place, that is, they do not move with the added line(s). To maintain them I would have to do all the editing in ExamDiff, and that may not be satisfactory. I'll try it for a while & see what happens.
Thank You,
-plh
arobustus
Junior Member
Posts: 13
Joined: Mon Aug 25, 2008 9:10 am

Re: Specify alignment of 2 files according to rule? (more)

Post by arobustus »

I manually linked all the lines that followed the rule I mentioned in earlier posts, because the double-headed arrow makes for a nice visual cue. Having done that, is there a way to make it ignore everything, leaving only the manually linked lines? I tried putting [:alnum:] in the text comparison options drop-down for "Lines matching regular expression" and it almost does it. I'm zipping the files along with the session. You can see that it still picks up on "G80". It also picks up on "G151G54(WORK OFFSET)" but I am assuming that is because I have not defined comments for this type of file. I guess I'd have to set up a new file type then specify "(" and ")" as comment delimiters.
Attachments
UberMatch3.zip
(24.96 KiB) Downloaded 846 times
arobustus
Junior Member
Posts: 13
Joined: Mon Aug 25, 2008 9:10 am

Re: Specify alignment of 2 files according to rule?(OOPS)

Post by arobustus »

Incorrect files in ZIP file. Here is the right one.
-plh
Attachments
UberMatch4.zip
(25.15 KiB) Downloaded 820 times
User avatar
psguru
Site Admin
Posts: 2396
Joined: Sat May 15, 2004 4:23 pm
Location: California
Contact:

Re: Specify alignment of 2 files according to rule?

Post by psguru »

It's not easy. You have to use something called "negative look-behind", and this will give you (perhaps almost) what you need:

\w+\b(?<!M\d\d\d)
psguru
PrestoSoft
arobustus
Junior Member
Posts: 13
Joined: Mon Aug 25, 2008 9:10 am

Re: Specify alignment of 2 files according to rule?

Post by arobustus »

Thank you. IIUYC, you mean that the negative look behind is for the line with the comment: "G151G54(WORK OFFSET)". What about the lines that just have "G80" on them? I don't see why they were not ignored along with lines like "M1" and "G28U0".
Thank You,
-plh
User avatar
psguru
Site Admin
Posts: 2396
Joined: Sat May 15, 2004 4:23 pm
Location: California
Contact:

Re: Specify alignment of 2 files according to rule?

Post by psguru »

The regex that I suggested will ignore all lines that don't have M followed by three digits.
psguru
PrestoSoft
arobustus
Junior Member
Posts: 13
Joined: Mon Aug 25, 2008 9:10 am

Re: Specify alignment of 2 files according to rule?

Post by arobustus »

What I would have to do is ignore all lines except those that have "M5" followed by two digits. Is that possible?
I just noticed to my horror that the manual links are not preserved in the session file. Is there a way to preserve them? They are the most critical thing for me.
Thank You,
-plh
arobustus
Junior Member
Posts: 13
Joined: Mon Aug 25, 2008 9:10 am

Re: Specify alignment of 2 files according to rule?

Post by arobustus »

I looks like I misread your post. :oops: "Ignore all lines except" is just what you said.
Can you help me out with the regex?
Thank You,
-plh
User avatar
psguru
Site Admin
Posts: 2396
Joined: Sat May 15, 2004 4:23 pm
Location: California
Contact:

Re: Specify alignment of 2 files according to rule?

Post by psguru »

I just noticed to my horror that the manual links are not preserved in the session file. Is there a way to preserve them?
Not in the current version. Our logic was that saving the links makes little sense because files can change between sessions. However, something about this will done in a future version.
Can you help me out with the regex?
Isn't the one I gave you working for for you?
psguru
PrestoSoft
Post Reply