Archive: checking version


checking version
Hello all,

I made a version check on installer startup.
It works as well, but i have a problem with the check in combination with Language selection.

That's my code:
Function .onInit
ReadRegStr $1 HKCU "Software\myapp" "Version"
StrCmp $1 "${MUI_VERSION}" 0 Abort
MessageBox MB_OK "You have the latest Version installed."
Abort:

;Language selection

;Font
Push Tahoma
Push 8

;Languages
!insertmacro MUI_LANGDLL_PUSH "English"
!insertmacro MUI_LANGDLL_PUSH "French"
!insertmacro MUI_LANGDLL_PUSH "German"
!insertmacro MUI_LANGDLL_PUSH "Spanish"
...
...
FunctionEnd

So when the installer starts up it shows me that i have already the latest version but when i click on OK the language selection window opens.

The installer should quit after the Abort.

Anyone who can help me ?


The Abort you have in your code is a label, not a command.
Do this:

Function .onInit
ReadRegStr $1 HKCU "Software\myapp" "Version"
StrCmp $1 "${MUI_VERSION}" 0 continue
MessageBox MB_OK "You have the latest Version installed."
Abort
continue:

;Language selection

;Font
Push Tahoma
Push 8

;Languages
!insertmacro MUI_LANGDLL_PUSH "English"
!insertmacro MUI_LANGDLL_PUSH "French"
!insertmacro MUI_LANGDLL_PUSH "German"
!insertmacro MUI_LANGDLL_PUSH "Spanish"
...
...
FunctionEnd


Another problem with your installer: If someone has the latest version installed and then runs an older installer, it will blow away the latest version and install an older version.
You need better version checking.
See Sunjammer's Dotted Comparison Script in the NSIS archive.


The script can be found here:
http://nsis.sourceforge.net/archive/...instances=0,11

BTW, I wrote it, not Sunjammer, but NP :)

-Hendri.


bad iceman_k :)


LOL @ Sunjammer :D


My bad. I should read the attributions more carefully.


Yep, but it's OK already. No big deal :)

What matters is that I hope that JXL and more people can use the script for their installer :)

Have fun, greetz,
-Hendri.


Many thanks, it works with your script.

All i need now is something to abort the installation when the check calls $0 or $1 and continue the installation on $2. It should have something like the continue tag to show the language window when $2 is called.


If I understand your question correctly: StrCmp the output of the script with '2'. If '2' then continue (go to some label). In the other case, continue and the installer will come across the abort and abort the installer. Just as iceman_k explained in the reply above.

Does that answer it?

-Hendri.


Could your show me a example ?



Push ${version number saved in registry}
Push ${version of software in installer}
Call VersionCheck
Pop $0
StrCmp $0 '2' Continue
Abort 'A newer or the same version of this software is already installed'

Continue:
...

But that is the same as iceman_k showed...

-Hendri.

This doesn't work for me.
I've added this:

Call VersionCheck
Pop $0
StrCmp $0 "2" continue 0
MessageBox MB_OK "You are updating from ($1) to (${MUI_VERSION})"
Abort

StrCmp $0 "0" 0 continue
MessageBox MB_OK "You have the latest MVersion installed."
Abort

StrCmp $0 "1" 0 continue
MessageBox MB_OK "You have already a newer version installed ($1). This is (${MUI_VERSION})"
Abort
continue:

What's wrong ?


Take a look at the labels. It will never visit the code where it compares the output of VersionCheck with '0' nor the part to compare with '1'. Add some additional labels:


Call VersionCheck
Pop $0
StrCmp $0 "2" 0 continue1
MessageBox MB_OK "You are updating from ($1) to (${MUI_VERSION})"
Goto continue

continue1:
StrCmp $0 "0" 0 continue2
MessageBox MB_OK "You have the latest MVersion installed."
Abort

continue2:
; [not necessary anymore] StrCmp $0 "1" 0 continue
MessageBox MB_OK "You have already a newer version installed ($1). This is (${MUI_VERSION})"
Abort

continue:

-Hendri.

Great, it works.
Sorry, i suck at scripting. It's my first project with NSIS.
Well, it's a great installer with many options but you have to read the whole docu to understand how the variables are working. And i couldn't find these continue or Abort labels to look at them how they works.

And big thx for your help.


NP, that's what we're here for :)

To clarify: the continue labels are custom labels, you can give them any name you want. As long as they end with ':' it is a custom label. Abort however is a function, not a label.

One more thing: the last StrCmp is not necessary anymore: if it is not a 2 nor a zero then it has to be a 1. So that one line can be deleted from the script...

Good luck scripting, greetz,
-Hendri.


warning
Quote:


Hi,

I love this function,

but I got this small warning,
install function "VersionCheck" not referenced - zeroing code (15-62) out


Can U guess why ?

Originally posted by Smile2Me
The script can be found here:
http://nsis.sourceforge.net/archive/...instances=0,11

BTW, I wrote it, not Sunjammer, but NP :)

-Hendri.


Are you actually calling VersionCheck, the makensis compiler doesn't think you are. If you are still unsure why you are getting this then attach your .nsi script here so we can help you work it out. Also can you tell us which version of NSIS you are using (2.0b4 CVS, 2.0b3, something else?)


I use 2.0b3,

I love 2 get my hands on a new yammi version
(I just download it three days ago - already got a new stuff ?)

and I just copied it from:
http://nsis.sourceforge.net/archive/...instances=0,11

Function VersionCheck
Exch $0 ;second versionnumber
Exch
Exch $1 ;first versionnumber
Push $R0 ;counter for $0
Push $R1 ;counter for $1
Push $3 ;temp char
Push $4 ;temp string for $0
Push $5 ;temp string for $1
StrCpy $R0 "-1"
StrCpy $R1 "-1"
Start:
StrCpy $4 ""
DotLoop0:
IntOp $R0 $R0 + 1
StrCpy $3 $0 1 $R0
StrCmp $3 "" DotFound0
StrCmp $3 "." DotFound0
StrCpy $4 $4$3
Goto DotLoop0
DotFound0:
StrCpy $5 ""
DotLoop1:
IntOp $R1 $R1 + 1
StrCpy $3 $1 1 $R1
StrCmp $3 "" DotFound1
StrCmp $3 "." DotFound1
StrCpy $5 $5$3
Goto DotLoop1
DotFound1:
Strcmp $4 "" 0 Not4
StrCmp $5 "" Equal
Goto Ver2Less
Not4:
StrCmp $5 "" Ver2More
IntCmp $4 $5 Start Ver2Less Ver2More
Equal:
StrCpy $0 "0"
Goto Finish
Ver2Less:
StrCpy $0 "1"
Goto Finish
Ver2More:
StrCpy $0 "2"
Finish:
Pop $5
Pop $4
Pop $3
Pop $R1
Pop $R0
Pop $1
Exch $0
FunctionEnd

If you have the function in your script, but don't actually have...

Call VersionCheck

...then the compiler will remove the function - because you haven't used it!

-Stu

Guess U R right :-)
Quote:


10X - I guess that was the reason
(suddenly it gives no S*IT)

Originally posted by Afrow UK
If you have the function in your script, but don't actually have...
Call VersionCheck

...then the compiler will remove the function - because you haven't used it!

-Stu