macrosinstallationinno-setup

Combine Inno Setup preprocessor #define from other #defines


I have an Inno Setup script.

In this Inno Setup script is a #define called InstallParameters. This is where the command line arguments for a program will go. The command line arguments will be any of four flags, /v, /i, /a, /c followed by arguments. For example, here would be an average input into InstallParameters:

#define InstallParameters "/v Local Area Connection /i 111.11.11.11"

Or:

#define InstallParameters "/a Device Name /c Customer Name"

Or:

#define InstallParameters "/v Local Area Connection /i 111.11.11.11 /a Device Name /c Customer Name"

Or any combination of a flag followed by an argument.

What I would like to do is make the four arguments into variables themselves, an amalgamation of #define.

Here is my ideal (please note that the syntax used to combine the #defineis entirely fictitious):

#define Connection "/v Local Area Connection"
#define IPaddress "/i 1.1.1.1"
#define DeviceName "/a Device Name"
#define CustName "/c Customer"

#define InstallParameters "{#Connection} {#IPaddress} {#DeviceName} {#CustName}"

Alas, none of the blind attempts I've tried have worked (some of them compile, though, which is nice).

Honestly, I don't know if this is a Pascal thing or an Inno Setup script thing. My attempts at the googles haven't resulted in anything worthwhile, because I don't know enough about either language/script to ask a worthwhile query.

Does anyone know if this sort of thing -- an amalgamation of #define -- is possible? And, if yes, how to do it?


Solution

  • #define directive can be followed by a C-like expression.

    In the expression, you can use + operator to concatenate strings (what you cannot actually use in C):

    #define InstallParameters Connection + " " + IPaddress + " " + DeviceName + " " + CustName
    

    See also Inno Setup Preprocessor: Expression Syntax. Though it is helpful only partially.