Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 15th February 2003, 22:17   #1
PhracturedBlue
Junior Member
 
Join Date: Feb 2003
Posts: 10
any way too do a '!if ${FOO} == 1'?

I am using NSIS to write an installer for the upcoming release of The Ur-Quan Masters
http://sc2.sf.net

And I'm pretty much done. However, I'd like the installer to be very easy to configure, and as such would really like to be able to do something like:
code:

!define FOO 1 ;Set FOO to 2, 1, or 0 depending on option
!if ${FOO} == 2
!define BAR "SOME_REALLY_CONVOLUTED_STRING"
!elseif ${FOO} == 1
!define BAR "SOME_OTHER_REALLY_CONVOLUTED_STRING"
!else
!define BAR "SOME_THIRD_REALLY_CONVOLUTED_STRING"
!endif



I realize that for 2 options, I could do:
code:

!define FOO 1 ;Comment this line if you don't want FOO
!ifdef ${FOO}
!define BAR "SOME_REALLY_CONVOLUTED_STRING"
!else
!define BAR "SOME_OTHER_REALLY_CONVOLUTED_STRING"
!define FOO 0
!endif



(Note that I need to define FOO, since I use it later in the installer)
Which works (and is how I'm doinng it now), but is somewhat confusing for the users, and doesn't allow for more than 2 options

Is there any more elegant way to do what I need?
(We are usiing 2.0b1)
(BTW: Thank you for NSIS! It is a wonderful project)
PhracturedBlue is offline   Reply With Quote
Old 15th February 2003, 22:20   #2
PhracturedBlue
Junior Member
 
Join Date: Feb 2003
Posts: 10
I should also mention that I've tried using IntCmp in a .onInit, but that requires thatI set the variable as $0-$9 (or $R0-$R9), or push it onto the stack, neither of which is really a viable option, since I have lots of variabbles I need to do this for.
PhracturedBlue is offline   Reply With Quote
Old 15th February 2003, 22:45   #3
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,898
well, your using the same "BAR" to define diferent strings...
.... try use the other "cmp" like StrCmp... for example:
code:

Function GetWinVer
Push $R0
Push $R1
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber
ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
StrCmp $R0 '4.00.950' Win95 NotWin95/NT3
StrCmp $R1 '3.51.1057' WinNT3 NotWin95/NT3
Win95:
SectionSetFlags ${descSQ} 16
WinNT3:
SectionSetFlags ${descSQ} 16
NotWin95/NT3:
FunctionEnd

Function GetIEVer
Push $R0
Push $R1
Push $1
GetDllVersion "$SYSDIR\mshtml.dll" $R0 $R1
IntOp $1 $R0 / 0x00010000 ;Necesitas el primer dígito/We only need the first digit
IntCmp $1 ${IEver} SameVer BadVer GoodVer ;Debe ser 5 o superior la versión
BadVer:
MessageBox MB_YESNO|MB_ICONSTOP "No version support" IDYES GoodVer
Abort
SameVer:
GoodVer:
FunctionEnd



Hope this help you!


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux w/ xfce4.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Debian unstable w/ xfce4.
Joel is offline   Reply With Quote
Old 16th February 2003, 09:28   #4
virtlink
Major Dude
 
virtlink's Avatar
 
Join Date: Sep 2002
Location: At [4C69:6E6B]
Posts: 561
I think that many people would like it to see !elseif added to NSIS. And it would take NSIS again one step closer to a 'real' scriptiong or programming language.

"I'll quote you when you say something memorable."
- Claudia Pelsmaeker
virtlink is offline   Reply With Quote
Old 16th February 2003, 11:13   #5
PhracturedBlue
Junior Member
 
Join Date: Feb 2003
Posts: 10
Using StrCmp doesn't buy me anything over an IntCmp in this case, and isn't very conveneient since this check is done in several places (this indicates that I'd need to do the compare in a function call, which I thought about, but it seems kinda silly to do a compare in the installer, when the actual string can be defined at compile-time instead).

Anyhow, I have a workable solution for now, and I really do appreciate all the nifty features in NSIS.

Thanks!
PhracturedBlue is offline   Reply With Quote
Old 16th February 2003, 12:43   #6
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
Quote:
Originally posted by virtlink
I think that many people would like it to see !elseif added to NSIS. And it would take NSIS again one step closer to a 'real' scriptiong or programming language.
Use "!else ifdef"
Joost Verburg is offline   Reply With Quote
Old 16th February 2003, 20:18   #7
PhracturedBlue
Junior Member
 
Join Date: Feb 2003
Posts: 10
Quote:
Originally posted by Joost Verburg
Use "!else ifdef"
That isn't quite the same as
!if
!elif
!endif

Which is what I'd like to see (and I imagine what virtlink was talking about)
PhracturedBlue is offline   Reply With Quote
Old 16th February 2003, 20:28   #8
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,338
!if something = somethingelse is not supported. You'll have to do with !ifdef, !else ifdef, and !endif for now. Instead of giving a value for your define make use of two different define names.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 17th February 2003, 22:56   #9
eccles
NSIS Dev
 
eccles's Avatar
 
Join Date: Sep 2001
Location: Leicester, UK
Posts: 193
This just occured to me but I've not tried it...
code:
!define FOO 1 ;Set FOO to 2, 1, or 0 depending on option

...

!define FOO${FOO}

!ifdef ${FOO2}
!define BAR "SOME_REALLY_CONVOLUTED_STRING"
!else ifdef ${FOO1}
!define BAR "SOME_OTHER_REALLY_CONVOLUTED_STRING"
!else
!define BAR "SOME_THIRD_REALLY_CONVOLUTED_STRING"
!endif


hth!

Dave.
eccles is offline   Reply With Quote
Old 18th February 2003, 02:44   #10
PhracturedBlue
Junior Member
 
Join Date: Feb 2003
Posts: 10
Very cool! i just tried this, and it works great. (of course you shouldn't have the '${' and '}' on the !ifdef lines (I screwed up the original proto code too)), so it looks more like:
code:

!define FOO 1 ;Set FOO to 2, 1, or 0 depending on option

...

!define FOO${FOO}

!ifdef FOO2
!define BAR "SOME_REALLY_CONVOLUTED_STRING"
!else ifdef FOO1
!define BAR "SOME_OTHER_REALLY_CONVOLUTED_STRING"
!else
!define BAR "SOME_THIRD_REALLY_CONVOLUTED_STRING"
!endif



But it does exactly what I need!

Thanks!
PhracturedBlue is offline   Reply With Quote
Old 18th February 2003, 07:18   #11
eccles
NSIS Dev
 
eccles's Avatar
 
Join Date: Sep 2001
Location: Leicester, UK
Posts: 193
Ar yes you're right. Like I said, I hadn't tried it

Glad I could help.
eccles is offline   Reply With Quote
Old 18th February 2003, 14:54   #12
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,338
Good idea eccles!

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 18th February 2003, 20:17   #13
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,898
works for me too


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux w/ xfce4.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Debian unstable w/ xfce4.
Joel is offline   Reply With Quote
Reply
Go Back   Winamp 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