Jump to content

What's the difference? StringCompare / ==


 Share

Recommended Posts

MsgBox(0, "Yes", _
        ('33' == '33') & @CRLF & _
        StringCompare('33', '33', 1))

Can I compare binary files, read with 0, instead of 16?

$hFile = FileOpen('D:\File1.avi', 0)
$sText1 = FileRead($hFile)
FileClose($hFile)

$hFile = FileOpen('D:\File2.avi', 0)
$sText2 = FileRead($hFile)
FileClose($hFile)

$timer1 = TimerInit()
$iRes1 = ($sText1 == $sText2)
$timer1 = Round(TimerDiff($timer1), 2) & ' msec'


$timer2 = TimerInit()
$iRes2 = StringCompare($sText1, $sText2, 1)
$timer2 = Round(TimerDiff($timer2), 2) & ' msec'

MsgBox(0, "Yes", $iRes1 & @Tab & ', Time ' & $timer1 & @LF & $iRes2 & @Tab & ', Time ' & $timer2)
Edited by AZJIO
Link to comment
Share on other sites

@AZJIO

This subject has already been discussed recently.

The == operator compare two strings and it's case sensitive, the difference with StringCompare (flag set to 1) is that the operator returns a boolean and StringCompare the ASCII difference value for the first different char found. More info here.

Yes you can compare files (read with 0), the comparison is made with the ASCII value of the characters.

Edit: Added some infos.

Edit2: I don't know if it's faster to compare two files according to their MD5 or something like that.

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...