Skip to content
⌘ NSIS Forum Archive

Need help this is confusing

11 posts

eyeinthesky43#

Need help this is confusing

Alright basically what I am trying to do is make a small updater that will download an ini file from the web and compare the version number in the ini with the ini file that is on the system and if the version number is newer then it will download the update. This is what I have:

NSISdl::download "http://www.site.com/new.ini" "C:\new.ini"

ReadINIStr $0 "C:\old.ini" "File Version" "Version"
ReadINIStr $1 "C:\new.ini" "File Version" "Version"
IntCmp $0 $1 lessthan$1 morethan$0
lessthan$1:
DetailPrint "No Update"
Goto done
morethan$0:
DetailPrint "Update"
NSISdl::download "http://www.site.com/Update.zip" "C:\Update.zip"
MessageBox MB_OK|MB_ICONINFORMATION "Downloaded file update!"
done:
The only part that seems to work is the first part that downloads new.ini, I'm a noob to NSIS so any help on this would be great.
Red Wine#
See documentation, 4.9.4.13 IntCmp

val1 val2 jump_if_equal [jump_if_val1_less] [jump_if_val1_more]

e.g.
intCmp $1 $0 no_download no_download download
eyeinthesky43#
Ugh ok I have been trying hard to figure this out but can't seem to get it, I read the documentation and changed the code which now it looks like it makes more sense and should work but sadly still not working like it should.

NSISdl::download "http://www.site.com/new.ini" "C:\new.ini"

ReadINIStr $0 "C:\old.ini" "File Version" "Version"
ReadINIStr $1 "C:\new.ini" "File Version" "Version"
IntCmp $0 $1 is$0 lessthan$0 morethan$0
is$0:
DetailPrint "No Updates"
Goto done
lessthan$0:
DetailPrint "No Updates"
Goto done
morethan$0:
DetailPrint "Updates"
NSISdl::download "http://www.site.com/Update.zip" "C:\Update.zip"
MessageBox MB_OK|MB_ICONINFORMATION "Downloaded file update!"
done:
Takhir#
1. Good idea is to get result code from stack (Pop) after every download - see NSISdl examples.
2. Use labels without $
3. Use MessageBox for debugging-tracing.
MessageBox MB_OK "old=$0 new=$1"
eyeinthesky43#
Ok so it's now setup just like you posted yet it's not downloading the update.zip:

NSISdl::download "http://www.site.com/new.ini" "C:\new.ini"

ReadINIStr $0 "C:\old.ini" "File Version" "Version"
ReadINIStr $1 "C:\new.ini" "File Version" "Version"
IntCmp $0 $1 jump_if_equal jump_if_$0_less jump_if_$0_more
jump_if_equal:
DetailPrint "No Updates"
Goto done
jump_if_$0_less:
DetailPrint "No Updates"
Goto done
jump_if_$0_more:
DetailPrint "Updates"
NSISdl::download "http://www.site.com/Update.zip" "C:\Update.zip"
MessageBox MB_OK|MB_ICONINFORMATION "Downloaded file update!"
done:
Could it be I have my ini files setup wrong and it's not reading them correctly? I mean I am pretty sure they are set up right:

new.ini text:
[File Version]
Version=1.1

old.ini text:
[File Version]
Version=1.0

Sorry for being a complete noob at this.....