User Command COMPARE (Dyalog)


COMPARE is a command used to compare 2 scripts or versions of scripts.

COMPARE is one of the SALT commands made into a user command.


SALT scripts are Unicode text files that can be compared just like any other text file.

There are several third party programs that can compare 2 files. This command is able to call them.


The command accepts an argument which is a path to either one or two scripts. The paths may be absolute or relative. In the latter case the 'workdir' settings (see UserCommands/SALT/Settings for details) will be used to find the items.

If the path is unique COMPARE will compare the last 2 versions of the script unless the -version switch is set.

COMPARE accepts a series of switches to alter its functionality:

If the version is unique and there are 2 files, the same versions of each file are compared.
If the version is unique and there is only one file the last version of the file is compare to the one specified.
If there are 2 version numbers and 2 files the versions of their corresponding file are compared.
If there are 2 version numbers and 1 file the two versions of that file are compared.
If the version number is 'ws' then the object that the script file defines is compared to the last version of the script.

If no external program is used to compare then APL itself is used and the following 2 switches are allowed:

Each group of differences is shown with a few lines (the "zone", default 2) before and after, like this:
 [7]  line 2/before
 [8]  line+1-before
→    line:that,was*inserted
←[9]  and this one was removed
 [10] line 1,after
 [11] and line 2 after


 ]COMPARE \my\own\function  -version=4 7
 ]COMPARE \my\own\function  -version=ws  -trim
 ]COMPARE my\script -use=C:\Program Files\Beyond Compare 3\Bcompare.exe -permanent


This script is part of the Dyalog product. For that reason this page is immutable.

The script is version 1.0 from 2007

Author: DanBaronet


UserCommands/SALT/Compare (last edited 2010-03-21 14:21:21 by KaiJaeger)