Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 14th September 2010, 13:19   #1
AMock
Junior Member
 
Join Date: Dec 2006
Location: Seltz, France
Posts: 4
NSIS Array: Problem when using user function in installer AND uninstaller

Hi,

I used NSISArray in some functions in an installer (install sections).
Now when I encapsulate the functions as macros to be able to use them in the
uninstaller too, I get
Quote:
!error: NSISArray: An array can only be initialised once.
Is there an elegant way to use the same user defined function using NSISArray both in installer and uninstaller parts. NSIS requests that uninstaller functions must be preceded by "un."

Code:
PHP Code:
!include NSISArray.nsh

${Array} "Devices" 40 5
${ArrayFuncInited
${ArrayFuncShift
${ArrayFuncSizeOf
${ArrayFuncReadFirst
${ArrayFuncReadNext
${ArrayFuncReadClose
!ifdef USE_DEBUGGER
${ArrayFuncDebug
!endif

!
macro Init_Devices un
Function ${un}Init_Devices
    
${Devices->Init}
FunctionEnd
!macroend

!macro Done_Devices un
Function ${un}Done_Devices
    
${Devices->Inited0 empty1
    
${Devices->Delete}
    
empty1:
FunctionEnd
!macroend
:
;+ 
other functions working on array Devicesdeclared as macros the same way
:
:
Installer section
!insertmacro Init_Devices ""

Uninstaller section
!insertmacro Init_Devices "un." 
AMock is offline   Reply With Quote
Old 14th September 2010, 13:25   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
You just need to define another array for use in the uninstaller.

Stu
Afrow UK is offline   Reply With Quote
Old 14th September 2010, 13:46   #3
AMock
Junior Member
 
Join Date: Dec 2006
Location: Seltz, France
Posts: 4
First I thought that I'd have to throw a lot of !ifdef...!endif into my functions....

But then I just put
PHP Code:
!include NSISArray.nsh

${Array} "Devices" 40 5
${ArrayFuncInited
${ArrayFuncShift
${ArrayFuncSizeOf
${ArrayFuncReadFirst
${ArrayFuncReadNext
${ArrayFuncReadClose
!ifdef USE_DEBUGGER
${ArrayFuncDebug
!endif

${Array} 
"un.Devices" 40 5
${ArrayFuncInited
${ArrayFuncShift
${ArrayFuncSizeOf
${ArrayFuncReadFirst
${ArrayFuncReadNext
${ArrayFuncReadClose
!ifdef USE_DEBUGGER
${ArrayFuncDebug
!endif

!
macro Init_Devices un
Function ${un}Init_Devices
    
${${un}Devices->Init}
FunctionEnd
!macroend

!macro Done_Devices un
Function ${un}Done_Devices
    
${${un}Devices->Inited0 empty1
    
${${un}Devices->Delete}
    
empty1:
FunctionEnd
!macroend 
and using ${un} in the worker functions accordingly:
e.g.
Call ${un}Init_Devices
Push 'PCI'
Call ${un}GetDeviceList
${${un}Devices->SizeOf} $R0 $R1 $R2

${${un}Devices->ReadFirst} $R0 $R1
${${un}Devices->ReadNext} $R0 $R1
${${un}Devices->ReadClose} $R0
Call ${un}Done_Devices

looks a little strange/cryptic, but the NSIS compiler no longer complains.

Thanks for the idea!
AMock 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