Jump to content
Sign in to follow this  
AZJIO

What's the difference? StringCompare / ==

Recommended Posts

AZJIO

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

Share this post


Link to post
Share on other sites
FireFox

@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

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
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
Sign in to follow this  

×