WINAMP.COM | Forums : Powered by vBulletin version 2.3.9 WINAMP.COM | Forums > Developer Center > NSIS Discussion > Installer and Uninstaller Redundancy
  Last Thread   Next Thread
Author
Thread Post New Thread    Post A Reply
Don Tommaso
Junior Member

Registered: May 2006
From: Stockholm

Question Installer and Uninstaller Redundancy

I'm a newbie to NSIS and I can't figure out how
to use the same functions for the installer and the uninstaller. Since the uninstaller functions must start
with the un-prefix and the installer functions must not,
my code is starting look horrible. E.g, I'm using
the EnumUsersReg.nsh module/file in both the installer and in the uninstaller and I had to copy the file and rename
every macro and function. Since no sensible language could
force this kind of redundancy I assume that it can be solved somehow. But how?

/Tomas

Quick Link | Report this post to a moderator | IP: Logged

Don Tommaso is offline Old Post 05-19-2006 09:51 AM
Click Here to See the Profile for Don Tommaso Click here to Send Don Tommaso a Private Message Find more posts by Don Tommaso Add Don Tommaso to your buddy list Edit/Delete Message Reply w/Quote
onad
Senior Member

Registered: Dec 2004
From: Turkey

It is not the language, but I agree sharing functions between Installer and Uninstaller could be improved.

Reason: Actually you are building TWO applications, an INSTALLER and an UNINSTALLER. Since you could need routines in your Installer you do not need in you uninstaller including them in both would make the unistaller unnessecair bigger filesize.

__________________
"Just do it"

Quick Link | Report this post to a moderator | IP: Logged

onad is offline Old Post 05-19-2006 11:07 AM
Click Here to See the Profile for onad Click here to Send onad a Private Message Find more posts by onad Add onad to your buddy list Edit/Delete Message Reply w/Quote
Don Tommaso
Junior Member

Registered: May 2006
From: Stockholm

Ok. But is it possible to achieve my goal somehow? I cannot
implement two versions of every function I'm using. It is madness!

Quick Link | Report this post to a moderator | IP: Logged

Don Tommaso is offline Old Post 05-19-2006 11:27 AM
Click Here to See the Profile for Don Tommaso Click here to Send Don Tommaso a Private Message Find more posts by Don Tommaso Add Don Tommaso to your buddy list Edit/Delete Message Reply w/Quote
kichik
M.I.A.
[NSIS Dev, Mod]

Registered: Oct 2001
From: Jerusalem, Israel

You can use a macro.

code:
!macro myfunc un Function ${un}myfunc Call ${un}someotherfunc DetailPrint something FunctionEnd !macroend !insertmacro myfunc "" !insertmacro myfunc "un."

__________________
NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius

Quick Link | Report this post to a moderator | IP: Logged

kichik is offline Old Post 05-19-2006 11:52 AM
Click Here to See the Profile for kichik Click here to Send kichik a Private Message Visit kichik's homepage! Find more posts by kichik Add kichik to your buddy list Edit/Delete Message Reply w/Quote
Don Tommaso
Junior Member

Registered: May 2006
From: Stockholm

Thanks, it works great!
You've saved my day.

Quick Link | Report this post to a moderator | IP: Logged

Don Tommaso is offline Old Post 05-19-2006 02:04 PM
Click Here to See the Profile for Don Tommaso Click here to Send Don Tommaso a Private Message Find more posts by Don Tommaso Add Don Tommaso to your buddy list Edit/Delete Message Reply w/Quote
onad
Senior Member

Registered: Dec 2004
From: Turkey

Thumbs up

Good codeing! Although obvious if you know it all....
.. but that is not the situation for everyone.

IDEA: Maybe somwhere to add example to the Wiki.

__________________
"Just do it"

Quick Link | Report this post to a moderator | IP: Logged

onad is offline Old Post 05-21-2006 08:12 PM
Click Here to See the Profile for onad Click here to Send onad a Private Message Find more posts by onad Add onad to your buddy list Edit/Delete Message Reply w/Quote
JasonFriday13
Senior Member

Registered: May 2005
From: Hawera, New Zealand

I have just made an example here.

__________________
"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
Wiki Profile

Quick Link | Report this post to a moderator | IP: Logged

JasonFriday13 is offline Old Post 05-22-2006 12:57 AM
Click Here to See the Profile for JasonFriday13 Click here to Send JasonFriday13 a Private Message Find more posts by JasonFriday13 Add JasonFriday13 to your buddy list Edit/Delete Message Reply w/Quote
Wabiloo
Member

Registered: Sep 2002
From:

Ah yes, but what happens if I want to use an existing function, like, say ${WordFind}?

PHP:

!macro myfunc un
Function ${un}myfunc
  
${WordFind} $CMDLINE "/" "E+$8" $7
  DetailPrint something
FunctionEnd
!macroend

!insertmacro myfunc ""
!insertmacro myfunc "un."



doesn't work (obviously)...

Quick Link | Report this post to a moderator | IP: Logged

Wabiloo is offline Old Post 09-13-2006 09:33 PM
Click Here to See the Profile for Wabiloo Click here to Send Wabiloo a Private Message Find more posts by Wabiloo Add Wabiloo to your buddy list Edit/Delete Message Reply w/Quote
Animaether
Major Dude

Registered: Jun 2001
From:

Then you adapt the existing function to a similar scheme

btw, this use of macros to create both an installer and an uninstaller function is in the NSIS help. It's sadly hidden in the "Scripting Structure > 2.3.6 Compiler Commands" topic, though.

Quick Link | Report this post to a moderator | IP: Logged

Animaether is offline Old Post 09-14-2006 06:03 PM
Click Here to See the Profile for Animaether Click here to Send Animaether a Private Message Find more posts by Animaether Add Animaether to your buddy list Edit/Delete Message Reply w/Quote
kichik
M.I.A.
[NSIS Dev, Mod]

Registered: Oct 2001
From: Jerusalem, Israel

code:
!macro myfunc un Function ${un}myfunc ${${un}WordFind} $CMDLINE "/" "E+$8" $7 DetailPrint something FunctionEnd !macroend !insertmacro myfunc "" !insertmacro myfunc "un."

__________________
NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius

Quick Link | Report this post to a moderator | IP: Logged

kichik is offline Old Post 09-15-2006 11:06 AM
Click Here to See the Profile for kichik Click here to Send kichik a Private Message Visit kichik's homepage! Find more posts by kichik Add kichik to your buddy list Edit/Delete Message Reply w/Quote
Wabiloo
Member

Registered: Sep 2002
From:

quote:

${${un}WordFind} $CMDLINE "/" "E+$8" $7



Oooh, I didn't know I could do that (really I should have tried before assuming, or read TFM...).
Just out of interest, is there any limit to the number of levels?

Quick Link | Report this post to a moderator | IP: Logged

Wabiloo is offline Old Post 09-15-2006 02:19 PM
Click Here to See the Profile for Wabiloo Click here to Send Wabiloo a Private Message Find more posts by Wabiloo Add Wabiloo to your buddy list Edit/Delete Message Reply w/Quote
kichik
M.I.A.
[NSIS Dev, Mod]

Registered: Oct 2001
From: Jerusalem, Israel

Nope, no limit.

__________________
NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius

Quick Link | Report this post to a moderator | IP: Logged

kichik is offline Old Post 09-15-2006 03:04 PM
Click Here to See the Profile for kichik Click here to Send kichik a Private Message Visit kichik's homepage! Find more posts by kichik Add kichik to your buddy list Edit/Delete Message Reply w/Quote
frodelan
Junior Member

Registered: Sep 2005
From:

Similar problem, but with macro which take a variable

I have following code in a .nsh file:

!define Test "!insertmacro Test"

!macro Test Var
Push "${Var}"
Call Test
!macroend

Function Test
Exch $0
.....
Pop $0
FunctionEnd

I call this macro from a .nsi file with:

${Test} "Value"

How should I use this in an Uninstall section? I have tried to do as explained in previous posts. I put my function Test inside a "DualFunction" macro like myfunc, but I got a error that said I have wrong number of parameters to my function call. Anyone that has a suggestion?

Best regards, Frode

Quick Link | Report this post to a moderator | IP: Logged

frodelan is offline Old Post 06-04-2009 12:04 PM
Click Here to See the Profile for frodelan Click here to Send frodelan a Private Message Find more posts by frodelan Add frodelan to your buddy list Edit/Delete Message Reply w/Quote
All times are GMT. The time now is 09:53 AM. Post New Thread    Post A Reply
  Last Thread   Next Thread
WINAMP.COM | Forums : Powered by vBulletin version 2.3.9 WINAMP.COM | Forums > Developer Center > NSIS Discussion > Installer and Uninstaller Redundancy
Show Printable Version
 | 
Email this Page
 | 
Subscribe to this Thread

Forum Jump:
 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is off
vB code is ON
Smilies are ON
[IMG] code is ON