Archive: Code Design Question


Code Design Question
Hi there,

i started 1 year ago with nsis to install 2 different appz with 2 different scripts. Now i have to deal with more than these 2 appz, so my wish is to rationalize some things.

I can code a little of e.g. vb or c++ etc., but shure nothing quite good cause thats not the major part of my work. But maybe you can bring me in the right direction, so i can read the rest in the docs:

Some parts of the 2 installations share exactly the same code - for each in every script. My plan was to put the doubled code outside as a NSI File and call it with the !include commando.

First time this was OK, but now i checked, that variables defined as global in the new NSI file are not known in the main script if i run the script in a other section (.oninit) than where i need the variable? Maybe i understand the word "global" in a wrong context???

For example: The external NSI should check if a dedicated app is install and detect things like version etc. (its the same to do for all appz). Inside the 2 different main scripts i want to do individual things depending of the detection routines in the external script.

At the moment i deal not with macros, cause i dont really understand the advantage/difference or how i call them correctly. But maybe macros could be my solution?

Bye


Using !include is effectively like inserting one text file into another, so you've got to remember that when you use it.

You could specify your global variables in the top of your header script but put everything else in macros. Then, when you want to include those macros you use !insertmacro anywhere in your script after the !include.

Stu


Thx Afrow UK for your reply. For all newbies out there ... i found a good explanation how to use Macros or Functions:

http://nsis.sourceforge.net/Macro_vs_Function

I think i change all of my external things into Macros which i call in the main script as you suggest ...