Archive: to un. or not to un. that is the question


to un. or not to un. that is the question
Hi!

This un./not un. stuff is driving me crazy. I am trying to use the Path manipulation code from http://nsis.sourceforge.net/wiki/Path_Manipulation in order to add my programs binary directory to the path under Windows NT/2000/XP in a persistent way but cannot get rid of those x&%!rgh-compiler errors related to the "un." prefix stuff. I would like to use the macro "RemoveFromPath" while in installer and uninstaller mode. It compiles but at the end says:

Processed 1 file, writing output:
Adding plug-ins initializing function... Done!
Error: resolving uninstall function "un.RemoveFromPath" in uninstall section "Uninstall" (0)
Note: uninstall functions must begin with "un.", and install functions must not
Error - aborting creation process

which reminds me of some odd problems I had in the past with this stuff (un.) ... I just would like to propose that in a future version we could simply be allowed to call un. functions while in installer mode. If I explicitely say "un.xxxx" the compiler could be nice and just pretends that I know that I want that function and not the installer-version of it...

But back to this problem:
Any hints what I can check?
I put the two functions AddToPath and RemoveFromPath as well as the rest of that utility stuff shown on the Wiki page in an include file "path.nsh" and include this at the beginning of my installer. What the heck can I do to let the pig fly?

Thanks in advance,
kind regards,
Heiko


NSIS compiller cannot share source code functions, all the code with 'un' prefix belongs to uninstaller only and will be used for uninstaller.exe compilation. The rest of code will be used in installer.exe build. May be in 3.0 version of NSIS ;) To use macro in both programs, use macro as the only content of 2 functions:


Function A2P
!macro AddToPath
FunctionEnd

Function un.A2P
!macro AddToPath
FunctionEnd

You could call the macro directly (!insertmacro XYZ). This may increase your code size if you do this more than once (inst+uninst) in your code. But I prefer this so I don't have the hassle with "un." for helper functions.

One more point: If you have a function you do not use, you get a warning. Macros don't cause warnings. So I think "pure macro" is a very practical solution for little helpers.