Archive: IntCmp not working for me


IntCmp not working for me
Hi

Trying to get code to check create date on a folder and then take actions if it matches, is older or newer.
I've started with the year, and the year gets read ok, but the integer comparision fails.

Any tips as to what I've done wrong?

Thanks
Mike


Name "DateTest"
OutFile "DateTest.exe"
AutoCloseWindow True
SilentInstall silent

!include "time.nsh"

Section
var /GLOBAL fileyear
var /GLOBAL filemonth

${time::GetFileTime} "c:\program files\ondemand" $0 $1 $2
;$0 = create date

StrCpy $fileyear $0 4 6 #
StrCpy $filemonth $0 2 3 #

Messagebox MB_OK $0
Messagebox MB_OK $fileyear
Messagebox MB_OK $filemonth

IntCmp $fileyear 2006 equal less more
equal:
MessageBox MB_OK "Equal file"
less:
MessageBox MB_OK "Old file"
more:
MessageBox MB_OK "New file"
done:

SectionEnd


Name "DateTest"
OutFile "DateTest.exe"
AutoCloseWindow True
SilentInstall silent

!include "time.nsh"

Section
var /GLOBAL day
var /GLOBAL month
var /GLOBAL year
var /GLOBAL hour
var /GLOBAL minute
var /GLOBAL second

${time::GetFileTime} "c:\program files\ondemand" $0 $1 $2
StrCmp $0 '' notexist

${time::TimeString} "$0" $day $month $year $hour $minute $second
IntCmp $year 2006 equal less more

equal:
MessageBox MB_OK "Equal file"
goto done

less:
MessageBox MB_OK "Old file"
goto done

more:
MessageBox MB_OK "New file"
goto done

notexist:
MessageBox MB_OK "File doesn't exist"

done:
${time::Unload}
SectionEnd

Hey - thanks loads for that!!!


You might want to try LogicLib.nsh (bundled with NSIS)... it's extremely handy for things like this.
Check out Examples\LogicLib.nsi

-Stu