1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need example of @COMPARE

Discussion in 'Support' started by deleyd, Nov 23, 2008.

  1. deleyd

    Joined:
    Aug 1, 2008
    Messages:
    16
    Likes Received:
    0
    I need a working example of how to use @COMPARE. I can not decipher the cryptic syntax. Then wrap it in an IF statement so I see the structure.

    Say I have files test1.exe and test2.exe, and I want to print out a message if they match or not.
     
  2. BillMc

    BillMc Guest

    On Sun 23-Nov-08 10:38pm -0600, deleyd wrote:

    .> I need a working example of how to use @COMPARE. I can not
    .> decipher the cryptic syntax. Then wrap it in an IF statement
    .> so I see the structure.
    .>
    .> Say I have files *test1.exe* and *test2.exe*, and I want to
    .> print out a message if they match or not.

    The function @compare returns true if the contents of two files
    are the same - the time stamps can be different.

    Here's your example:

    if %@compare[test1.exe,test2.exe] == 1 (echo Equ) else (echo Neq)

    Of course, if you want it to be more robust, create a batch file.
    Below is a batch file called compare.btm:

    iff "x%1" == "x" .or. "x%2" == "x" then
    echo Usage: compare file1 file2
    quit
    elseiff %@index[%1,ftp:] != -1 .and. %@index[%2,ftp:] != -1 then
    echo Both files may not be FTP files
    quit
    elseiff not isfile "%1" then
    echo "%1" isn't a file!
    if not isfile "%2" echo "%2" isn't a file!
    quit
    elseiff not isfile "%2" then
    echo "%2" isn't a file!
    quit
    elseiff %@compare[%1,%2] eq 1 then
    echo They match!
    else
    echo They do not match.
    endiff

    --
    Best regards,
    Bill
    4nt 8.02.106 / tcmd 9.02.152 cp 2.11.34 on xp pro sp3
     

Share This Page