SPFLite provides a built-in DIFF file compare tool.  While this is not as comprehensive as an external DIFF tool, like KDiff3, CSDiff or WinDIff, it should prove quite useful for most file compare operations.


DIFF Features

Invoking DIFF with an Options Dialog

Invoking DIFF via the command line

The DIFF 1 Column Output description

The DIFF 2 Column Output description


Features:

    • If the files being compared are already loaded into SPFLite tabs, then the entire operation is performed with no external I/O and is extremely fast.
    • The Output report is displayed using normal SPFLite Edit display. This means that all normal editing commands are available to you (EXCLUDE, CUT, PASTE  etc.)
    • DIFF reports are created as temporary CLIP files and will thus be kept available for two days in the \CLIP folder.  The temporary CLIP name will include the names of the two files being compared, date/time of the run and View type.
    • Retrieval of these 'kept' reports can be done with a DIFF LIST command which will allow you to choose between available reports.
    • User control of the color highlighting of deleted and inserted lines.  Options => Screen has options to allow you to choose exactly how you would like the report to be colored.
    • DIFF options to choose 1 column or 2 column format output.
    • Difference lines are automatically marked as User Lines, meaning a LOCATE U commad can be used to quickly scroll down to the next difference. Note: LOCATE also will accept LOCATE DIFF as an alias as it seems more 'logical' to think of it that way.
    • Flexible algorithm matching criteria.  This can help in grouping line changes into larger 'chunks' which can visually improve the comparison.
    • Ability to suppress displays of lines which match.
    • Ability to exclude selected lines from the compare (e.g X or NX lines).
    • Ability to compare only within specified BOUNDS for each file.
    • Ability to compress multiple spaces down to 1 space before the compare.
    • Ability to 'collapse' multiple consecutive blank lines down to a single line.
    • Ability to do a case-insensitive compare.
    • Ability to ignore embedded TAB characters if present.
    • Ability to ignore Source Code comments if the files have valid AUTO colorization files


Invoking a DIFF Compare


SPFLite allows you to invoke DIFF and specify the files and options to be used in a variety of ways. You may choose whichever suits your own working style.


Options Dialog


This option if invoked with a simple DIFF command, with no operands.  You will be presented with the following dialog:


FileA and FileB 

These input boxes will be populated with a list of the currently Open files in SPFLite.  You may select the files you wish to compare from the drop-down list.  


If a desired file is not currently Open, click the Open Other button, a normal file selection dialog will appear and you can locate and select your file.  The file will be loaded into a new Edit Tab.


Limit comparison to BOUNDS

You may specify the Bounds within which the comparison will be made,  Enter the Left and Right Bounds as two values separated by a comma.  See BOUNDS for details on Bounds usage.


Lines to Exclude from Diff:

Specify what lines (if any) you wish to exclude from the DIFF comparison.  You may select None, NX Lines or X Lines.


Options

The following options for the DIFF comparison may be chosen, they are all independent and may be chosen in any combination.


Ignore multiple spaces

This will treat all strings of multiple spaces as if they are a single space.

Case insensitive compare

This will do all compares ignoring differences in text case.

Ignore Tabs

This will treat all embedded TAB characters as if they are a single space.

Ignore Comments

This will, if the file type has as associates AUTO file, cause the comments in Source text to be ignored.   

Comment types where the remainder of a line is a comment, will be truncated.

Bracketed comments (like /* ... */) will be replaced with spaces.


Min. # of matching lines to be called a 'Match'

This number is used when the DIFF process is attempting to re-synchronize lines following some deletions or insertions. It indicates how many consecutive matching lines must be found before considering things are 'back in sync'.  The default is 5, which for most program source type text files seems to produce the best report.   This is a personal preference item which you should experiment with to find what works best for you.


Collapse Blank lines

If selected, a consecutive sequence of blank lines in a file will be reduced to a single blank line.  If you are also using "Lines to Exclude from Diff" (above), then the collapse of blank lines is done after the X/NX filtering is done.


View

These options allow you to select the formatting of the DIFF output report.


Single column view

Select this to request a Single Column report, un-select to request a Two-Column report. See the descriptions of the two report types below.

Use FileB as source for unchanged lines

When 1Column view is selected, and the FileA and FileB lines are considered a match, the report only shows the data from one file.  After all, they're supposed to  match.


But when options like Case Insensitive, Space compression, Comment removal etc. are used, the FileA and FileB data may actually be somewhat different.


Normally, DIFF will use the FileA data to display, this option allows you to request that the display show the FileB data instead.


Do not display matching lines

If Selected, the DIFF report will not display lines considered to be a match, only differences.



Press Done when you have made your choices.


Other than the File Names, all the option settings will be retained and used as the defaults for future DIFF requests.


An exception to this is the FileA and FileB Bounds values, these will be saved only during the current day and will be reset to 1,MAX the next day.


Using the DIFF command with operands


The format of the DIFF command in full is:


DIFF                { [ FileA-TabNum | FileA-filename ] }

         { [ FileB-TabNum | FileB-filename ] }


OR


DIFF LIST


Once you enter the command, you will still be presented with the Option dialog described above where you can choose the other possible options for the DIFF operation.



Operands


[ FileA-TabNum | FileA-filename ]

[ FileB-TabNum | FileB-filename ]


DIFF compare requires two files, these operands allow you to specify the file in one of three ways, whichever is more convenient for you.


Filex-TabNum

You may enter a .simple number to indicate the Tab # currently containing the desired file.  The File Manager tab is 1, the next tab to the right is 2 etc.  Tab 1 (FM) is not allowed.


Filex-FileName

You may enter the full name of the desired file.  This can be a file currently open in one of the tabs, or some other file not currently Open.  If a file is not currently Open, it will be loaded into a new tab prior to the DIFF compare.




LIST


If LIST is the only operand, you will be presented with a pull-down list of all available DIFF reports you have created in the last couple days.  Simply choose the one desired and it will be opened for review.



Invoking DIFF from the File Manager


You may invoke DIFF in File Manager by selecting the two files to be compared using the DFA and DFB line commands.



The DIFF 1 Column Output description


The 1 column output report shows the line numbers of the data in the FileA and FileB files on the left hand side.  Where a line exists on one side and not on the other, the line number is replaced by ----- or +++++.   The text for all lines is complete and if needed, the screen can be scrolled to the right to view all of it.  Here's a sample report showing the various types of differences.


Note lines 9-10, 15-16, 22 and 27-29 are all marked as User Lines.  For large difference reports this means you can use a LOCATE U (ot LOCATE DIFF) command to quickly scroll down to the next actual difference.



Lets look at some lines in detail.



Here we can see that FileA Line 00012 is not present in FileB (the ----- line number).  The line is highlighted as a deletion according to what was specified in Options -> Screen.


The lines above and below the deleted lines are present in both FileA and FileB as there are valid line numbers for each line in each file. These lines are displayed in your normal text colors.


Here's another detail:



We can see lines 00018, 00019 and 00020 in FileB have no matching line in FileA - they are all +++++.  This is an insertion and is colored as per the setting in Options => Screen.  Again the lines before and after the insertion lines are normal, unchanged matching lines.


One more detail:



This shows a simple modification of a line.  In order to show you both versions of the modified line, it takes two lines in the report. They are colored as a Deletion followed by an insertion.  Note that both FileA and FileB line numbers are the same - 00002



  The DIFF 2 Column Output description


The 2 column output report shows the lines from the two files side by side, which is normally the simplest visual organization to understand.  Where a line exists on one side and not on the other, the line number is blanked.   SPFLite will adjust the widths of the two columns to the maximum that can fit in your displayed screen width.   Because these are fixed-width, non-scrollable columns, only as much data as will fit is shown. Side scrolling of the columns in not supported, so it is advisable to make your screen as wide as possible (Full Screen?)


Here's a sample report showing the various types of differences.  This is the exact same file compare that was shown above in the 1 column description.


Note lines 9, 14-15, 21, and 26-28 are all marked as User Lines.  For large difference reports this means you can use a LOCATE U command to quickly scroll down to the next actual difference.



Lets look at some lines in detail.



Here we can see that FileA Line 00012 is not present in FileB (the right side is blank).  The center divider is a < character used to highlight FileA deletions.  The line is also highlighted as a deletion according to what was specified in Options -> Screen.


The lines above and below the deleted lines are present in both FileA and FileB as there are valid line numbers for each line in each file. These lines are displayed in your normal text colors and the center divider is a | character.


Here's another detail:



We can see lines 00018, 00019 and 00020 in FileB have no matching line in FileA - the left side is blank.  This is an insertion and is colored as per the setting in Options => Screen.  The center divider is a > to indicate  an insertion.  Again the lines before and after the insertion lines are normal, unchanged matching lines.


One more detail:



This shows a simple modification of a line.  They are colored as a Deletion / Insertion and the center character is a ~ 


Two Column Center Divider Characters


The use of different characters in the center divider column is to provide easy selection of the different line types.  Since the DIFF report is displayed using a normal CLIP window, you have the full range of SPFLite commands available to Exclude Lines, Delete any unwanted lines, etc.

  

Created with the Personal Edition of HelpNDoc: Streamline Your Documentation Creation with a Help Authoring Tool