Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 25th March 2005, 12:15   #1
Faith Healer
Junior Member
 
Join Date: Mar 2005
Location: Russian Federation, Moscow
Posts: 7
Send a message via ICQ to Faith Healer
WinVer and variables troubles (+)

Good day everybody

I'm using NSIS not for long time (less than 4 months), often read this NSIS-related forum, read docs + using search (maybe miss something), etc.

I use NSIS for my MirandaIM pack installer, which globaly (for full installation) detects Windows version and depending on it installs needed/proper files.
I decided to advance/modify/optimize code, but got some troubles which I can't resolve, feeling dumb

So, I have files:
tabsrmm.dll
tabsrmm_unicode.dll
tabsrmm_icons_faith_brq_2k.dll
tabsrmm_icons_faith_brq_xp.dll


so, I need to copy files:
* if WinVer is unknown then copy
tabsrmm.dll + tabsrmm_icons_faith_brq_2k.dll (but without "_2k" in the name)
* if WinVer is Win2k then copy
tabsrmm_unicode.dll + tabsrmm_icons_faith_brq_2k.dll (without "_2k" in the name)
if WinVer is WinXP/2k3 then copy
tabsrmm_unicode.dll + tabsrmm_icons_faith_brq_xp.dll
(without "_xp" in the name)

my code is
PHP Code:
Function .onInit
   ReadRegStr $WinVer HKLM 
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion" CurrentVersion
    StrCmp $WinVer 
"5.0" win2k
    StrCmp $WinVer 
"5.1" winxp
    StrCmp $WinVer 
"5.2" winxp

     StrCpy $icons 
"2k"
     
StrCpy $unicode ""
         
Goto endwinver

        win2k
:
    
StrCpy $icons "2k"
    
StrCpy $unicode "_unicode"
         
Goto endwinver

        winxp
:
    
StrCpy $icons "xp"
    
StrCpy $unicode "_unicode"
        
endwinver:
FunctionEnd 
PHP Code:
Section "tabSRMM v0.9.9.9" SecTabSRMM
    SectionIn 1 2 3
    SetOverwrite on
    SetOutPath 
"$INSTDIR\\Plugins"
    
File "..\\Plugins\\tabsrmm${unicode}.dll"
    
File /oname=tabsrmm_icons.dll "..\\Icons\\tabsrmm_icons\\tabsrmm_icons_faith_brq_${icons}.dll"
SectionEnd 
And it doesn't works - when I'm compilate this it complains:
File: "..\Icons\tabsrmm_icons\tabsrmm_icons_faith_brq_${icons}.dll" -> no files found.
in fact that files
tabsrmm_icons_faith_brq_2k.dll
tabsrmm_icons_faith_brq_xp.dll
exist

Thank you for any help
Faith Healer is offline   Reply With Quote
Old 25th March 2005, 13:18   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
You're getting confused with run-time and compile-time commands.

You need to do the checks inside your section, and jump over File calls for certain conditions.

-Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 25th March 2005, 14:25   #3
Faith Healer
Junior Member
 
Join Date: Mar 2005
Location: Russian Federation, Moscow
Posts: 7
Send a message via ICQ to Faith Healer
Hmmm... Looks like I don't understand
So, how to make it work globally, not only in one section...
It would be excellent to get short example (or hint) of it

Last edited by Faith Healer; 25th March 2005 at 14:52.
Faith Healer is offline   Reply With Quote
Old 27th March 2005, 19:39   #4
std
Guest
 
Posts: n/a
but, Afrow UK, is it really no way to use runtime string substitution for this case?
  Reply With Quote
Old 27th March 2005, 19:43   #5
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
No, there is no way. The compiler can't guess every possible value the runtime variable might have and compress all of the matching files.

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 28th March 2005, 04:32   #6
Faith Healer
Junior Member
 
Join Date: Mar 2005
Location: Russian Federation, Moscow
Posts: 7
Send a message via ICQ to Faith Healer
kichik, but I've defined exactly:
PHP Code:
     StrCpy $icons "2k" 
     
StrCpy $unicode "" 
         
Goto endwinver 

        win2k

    
StrCpy $icons "2k" 
    
StrCpy $unicode "_unicode" 
         
Goto endwinver 

        winxp

    
StrCpy $icons "xp" 
    
StrCpy $unicode "_unicode" 
))
so, $icons can have 2 values = "2k" or "xp", $unicode can have only 2 values too - "" (empty) and "_unicode".

I totaly dislike old my code:
1st var:
PHP Code:
Section "tabSRMM 0.9.9.91" tabsrmm
    SectionIn 1 2 3
    SetOutPath 
"$INSTDIR\\Plugins"
    
SetOverwrite on
    File 
"..\\Plugins\\smileyadd.dll"
     
ReadRegStr $R0 HKLM "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion" CurrentVersion
        StrCmp $R0 
'5.0' unicode
        StrCmp $R0 
'5.1' unicode
        StrCmp $R0 
'5.2' unicode

                File 
"..\Plugins\tabsrmm.dll"
                    
Goto tabicons

                    unicode
:
                
File "..\Plugins\tabsrmm_unicode.dll"
                    
Goto tabicons

            tabicons
:
     
ReadRegStr $R0 HKLM "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion" CurrentVersion
        StrCmp $R0 
'5.1' xpicons
        StrCmp $R0 
'5.2' xpicons

                File 
/oname=tabsrmm_icons.dll "..\Icons\tabsrmm_icons\tabsrmm_icons_faith_brq_2k.dll"
                    
Goto endtabsrmm

                    xpicons
:
                
File /oname=tabsrmm_icons.dll "..\Icons\tabsrmm_icons\tabsrmm_icons_faith_brq_xp.dll"
                    
Goto endtabsrmm
                        endtabsrmm
:
SectionEnd 
2nd var:
PHP Code:
Section "tabSRMM 0.9.9.91" tabsrmm
    SectionIn 1 2 3
    SetOutPath 
"$INSTDIR\\Plugins"
    
SetOverwrite on
    File 
"..\\Plugins\\smileyadd.dll"
     
ReadRegStr $R0 HKLM "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion" CurrentVersion
        StrCmp $R0 
'5.0' win2k
        StrCmp $R0 
'5.1' winxp
        StrCmp $R0 
'5.2' winxp

                File 
"..\Plugins\tabsrmm.dll"
                
File /oname=tabsrmm_icons.dll "..\Icons\tabsrmm_icons\tabsrmm_icons_faith_brq_2k.dll"
                    
Goto endtabsrmm

                    win2k
:
                
File "..\Plugins\tabsrmm_unicode.dll"
                
File /oname=tabsrmm_icons.dll "..\Icons\tabsrmm_icons\tabsrmm_icons_faith_brq_2k.dll"
                    
Goto endtabsrmm

                    winxp
:
                
File "..\Plugins\tabsrmm_unicode.dll"
                
File /oname=tabsrmm_icons.dll "..\Icons\tabsrmm_icons\tabsrmm_icons_faith_brq_xp.dll"
                        
endtabsrmm:
SectionEnd 
So, maybe fix/add it in NSIS to work with it?
Faith Healer is offline   Reply With Quote
Old 28th March 2005, 06:25   #7
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
No such feature will be added to NSIS. As I've said in the previous reply, the compiler can't guess which values the runtime variable will contain. For all it knows, the runtime variable can depend on the user's host name.

Best you can do is create a macro and insert it three times with different parameters.
code:
!macro install srmm_postfix icons_postfix
File "..Plugins\tabsrmm_${srmm_postfix}.dll"
File /oname=tabsrmm_icons.dll "tabsrmm_icons_${icons_postfix}.dll"
!macroend
!insertmacro install "" ""
!insertmacro install "unicode" "2k"
!insertmacro install "unicode" "xp"


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 28th March 2005, 06:37   #8
Faith Healer
Junior Member
 
Join Date: Mar 2005
Location: Russian Federation, Moscow
Posts: 7
Send a message via ICQ to Faith Healer
sad then

thank you very much for the macro, I'll try it
Faith Healer 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