Old 24th September 2010, 19:34   #1
Squirre1
Member
 
Join Date: Aug 2001
Posts: 55
Send a message via ICQ to Squirre1
Integrate VersionCheckNew with If..Else..Endif

Is there a way that you can inteagrate VersionCheckNew into LogicLib for easier logic comparison... For Example:

code:

${If} ${VersionCheckNew} "$detectedver" "9.3.0" == 2
//do stuff here
${ElseIf} ${VersionCheckNew} "$detectedver" "9.3.3" == 1
//do stuff here
${ElseIf} ${VersionCheckNew} "$detectedver" "9.3.1" == 0
//do stuff here
${ElseIf} ${VersionCheckNew} "$detectedver" "9.3.2" == 0
//do stuff here
${ElseIf} ${VersionCheckNew} "$detectedver" "9.3.3" == 0
//do stuff here
${EndIf}



I know there are many more ways to write this, I am just asking in general...

Thanks All.

Squirre1
Squirre1 is offline   Reply With Quote
Old 24th September 2010, 20:09   #2
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
You can extend LogicLib, yes, but not the way you're writing it right now, of course

Probably the best approach would be to add comparison logic operators, a la (I'm using ${VersionCompare} out of WordFunc.nsh):
PHP Code:
/* Version tests */
!insertmacro `_LOGICLIB_TEMP/* required */

!macro _V_a _b _t _f
  
${VersionCompare} ${_a} ${_b$_LOGICLIB_TEMP
  IntCmp $_LOGICLIB_TEMP 0 
`${_t}` `${_f}` `${_f}`
!
macroend

!macro _V<> _a _b _t _f
  
!insertmacro _V= `${_a}` `${_b}` `${_f}` `${_t}`
!
macroend

!macro _V_a _b _t _f
  
${VersionCompare} ${_a} ${_b$_LOGICLIB_TEMP
  IntCmp $_LOGICLIB_TEMP 2 
`${_t}` `${_f}` `${_f}`
!
macroend

!macro _V<= _a _b _t _f
  
!insertmacro _V> `${_a}` `${_b}` `${_f}` `${_t}`
!
macroend

!macro _V_a _b _t _f
  
${VersionCompare} ${_a} ${_b$_LOGICLIB_TEMP
  IntCmp $_LOGICLIB_TEMP 1 
`${_t}` `${_f}` `${_f}`
!
macroend

!macro _V>= _a _b _t _f
  
!insertmacro _V< `${_a}` `${_b}` `${_f}` `${_t}`
!
macroend 
Usage example for experimenting:
PHP Code:
!include "LogicLib.nsh"
!include "WordFunc.nsh"

OutFile "$%temp%\temp.exe"
Section

[version compare code goes hereperhaps in an include, or maybe you put it in LogicLib.nsh directly]

Section
  StrCpy 
$"1.0.0.0"
  
StrCpy $"1.0.0.1"
  
${If} "$0" V"$1"
    
MessageBox MB_OK "$0 = $1"
  
${EndIf}
  ${If} 
"$0" V<> "$1"
    
MessageBox MB_OK "$0 <> $1"
  
${EndIf}
  ${If} 
"$0" V"$1"
    
MessageBox MB_OK "$0 < $1"
  
${EndIf}
  ${If} 
"$0" V<= "$1"
    
MessageBox MB_OK "$0 <= $1"
  
${EndIf}
  ${If} 
"$0" V"$1"
    
MessageBox MB_OK "$0 > $1"
  
${EndIf}
  ${If} 
"$0" V>= "$1"
    
MessageBox MB_OK "$0 >= $1"
  
${EndIf}
SectionEnd 
Animaether is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump