Inno Setup Preprocessor: Introduction

The main purpose of Inno Setup Preprocessor (ISPP) is to automate compile-time tasks and avoid repetition in your scripts. For example, you can declare a compile-time ISPP variable – containing your application name, for instance – and then use its value in several places of your script. If for some reason you need to change the name of your application, you'll have to change it only once in your script. Without ISPP, you would need to change all occurrences of your application name throughout the script.

Another example of using ISPP would be gathering version information from your application at compile-time by reading the version info of an EXE file, and using it in your AppVerName [Setup] section directive or anywhere else. Without ISPP, you would have to modify your script each time the version of your application changes.

ISPP can even scan your source folder and generate script lines for the found files. Without ISPP, you would have to manually maintain the list of files.

Conditional in- and exclusion of portions of script is also possible by using ISPP: you can create one single script for different versions/levels of your applications (for example, trial versus fully functional). Without ISPP, you would need multiple scripts.

Finally, ISPP makes it possible to split long lines using a line spanning symbol.

Note: ISPP works exclusively at compile-time, and has no run-time functionality.

All topics

  • Example Script
  • Directives Reference
  • Support Functions Reference
  • User Defined Functions
  • Expression Syntax
  • Predefined Variables
  • Line Spanning
  • ISPPBuiltins.iss
  • Visibility of Identifiers
  • Command Line Compiler Execution
  • Preprocessor output
  • Current preprocessor output


Inno Setup Preprocessor: Directives Reference

There are two kinds of directives in ISPP: simple and inline.

Simple directives occupy a whole line and begin with the # symbol. For example the following defines a variable called MyAppName:

#define MyAppName "My Program"

Inline directives appear inside other lines and begin with {# and end with }. For example the following sets Inno Setup's AppName directive to the value of the previously defined variable:

[Setup]
AppName={#MyAppName}

As seen in the above example it is not necessary to specify the name of the emit directive when it is used inline, so {#MyAppName} is short for {#emit MyAppName}.

Directive syntax documenting conventions

Directive usage syntax uses the following conventions.

() | Group of tokens.
[] | Optional token or group of tokens.
| | Mutually exclusive tokens.
... | Previous token or group of tokens can be repeated.
token | Reserved word or symbol(s). Must be typed exactly as shown.
<token> | Non-terminal. Its syntax is either shown before, or explained.

Available directives

  • #define
  • #dim, #redim
  • #undef
  • #include
  • #file
  • #emit
  • #expr
  • #insert
  • #append
  • #if, #elif, #else, #endif
  • #ifdef, #ifndef, #ifexist, #ifnexist
  • #for
  • #sub, #endsub
  • #pragma
  • #error


Inno Setup Preprocessor: Support Functions Reference

There are a number of built-in support functions which you can use to perform compile-time actions and/or change your script. For example the following uses ISPP function GetVersionNumbersString to read version info from an EXE and uses the return value of the function to set the AppVerName [Setup] section directive using ISPP directive emit:

#define MyAppVer GetVersionNumbersString(AddBackslash(SourcePath) + "MyProg.exe")

[Setup]
AppVerName=MyProg version {#MyAppVer}

Function prototypes documenting conventions

Function prototypes show the function result type, name, and parameters.

Return and parameter types int, str, any, and void respectively specify the integer type, the string type, any type, and the null type. The integer type is a signed 64-bit integer. When the null type is specified as a function result type then the function does not return a value.

A question mark (?) after an parameter type means that the parameter is optional.

Available functions

  • AddBackslash
  • AddQuotes
  • ChangeFileExt
  • ComparePackedVersion
  • Copy
  • CopyFile
  • DecodeVer
  • Defined
  • Delete
  • DeleteFile
  • DeleteFileNow
  • DimOf
  • DirExists
  • EncodeVer
  • EntryCount
  • Error
  • Exec
  • ExecAndGetFirstLine
  • ExtractFileDir
  • ExtractFileExt
  • ExtractFileName
  • ExtractFilePath
  • FileClose
  • FileEof
  • FileExists
  • FileOpen
  • FileRead
  • FileReset
  • FileSize
  • Find
  • FindClose
  • FindCode
  • FindFirst
  • FindGetFileName
  • FindNext
  • FindSection
  • FindSectionEnd
  • ForceDirectories
  • GetDateTimeString
  • GetEnv
  • GetFileDateTimeString
  • GetMD5OfFile
  • GetMD5OfString
  • GetMD5OfUnicodeString
  • GetPackedVersion
  • GetSHA1OfFile
  • GetSHA1OfString
  • GetSHA1OfUnicodeString
  • GetStringFileInfo
  • GetVersionComponents
  • GetVersionNumbers
  • GetVersionNumbersString
  • Insert
  • Int
  • IsWin64
  • Len
  • LowerCase
  • Max
  • Message
  • Min
  • PackVersionComponents
  • PackVersionNumbers
  • Pos
  • Power
  • ReadIni
  • ReadReg
  • RemoveBackslash
  • RemoveFileExt
  • RPos
  • SamePackedVersion
  • SameStr
  • SameText
  • SaveStringToFile
  • SaveToFile
  • SetSetupSetting
  • SetupSetting
  • Str
  • StringChange
  • StrToVersion
  • Trim
  • TypeOf
  • UnpackVersionComponents
  • UnpackVersionNumbers
  • UpperCase
  • VersionToStr
  • Warning
  • WriteIni
  • YesNo


Inno Setup Preprocessor: User Defined Functions

You can define user defined functions.

A user defined function declaration consists of a formal parameter list and an expression. That expression is evaluated when the function is called (see below). The result of the function call is the result of the expression. The expression can contain parameter names, they are treated as usual variables.

The formal syntax of a user defined function is provided in define and ISPPBuiltins.iss contains many example functions.

Please note that there must be no space between the function name and opening parenthesis.

Actual parameters for parameters declared as by-reference must be modifiable l-values (in other words, other defined variables or expressions that evaluate to l-values). If the expression modifies by-reference parameter, the variable that is passed as this parameter gets modified. By-value parameters can also be modified by the expression (using assignment operators), but this modification doesn't affect the value of a variable which could be passed as this parameter.

Though a user defined function can only contain one expression, sequential evaluation operators (comma), assignment operators (simple and compound) and conditional operators (?:) can be used to build more complicated functions.

Local array

In context of the expression, an additional array named Local is valid. Its elements can be used for temporary storage and reusing values in sequential expressions. Values stored in Local array are neither preserved from call to call (including recursive), nor are they accessible from anywhere except the expression.

#define DeleteToFirstPeriod(str *S) /* user defined function declaration */ \
  Local[1] = Copy(S, 1, (Local[0] = Pos(".", S)) - 1), \
  S = Copy(S, Local[0] + 1), \
  Local[1]


Inno Setup Preprocessor: Expression Syntax

ISPP uses C/C++-like expression syntax. It supports simple and compound assignment operators, conditional operator, and sequential evaluation operator. Although ISPP is an interpreter, it does support short circuit boolean evaluation and never evaluates expressions (nor calls any user defined functions mentioned in those expressions) that should not be evaluated due to specific rules (for example, when conditional operator is used, always only 2 out of 3 operands are evaluated).

ISPPBuiltins.iss contains many example expressions.

Differences between C and ISPP expression syntax

  • ISPP does not support a number of operators (reference, dereference, namespace resolution, member selection, etc.).
  • ISPP treats an identifier and the equality sign as a name of an parameter, if it is used in parameter list.
  • Arithmetic division operator (slash) performs integer division, since ISPP does not support floating point math.
  • ISPP does not check for validity of expressions in certain cases. For example, in conditional expression, "true" operand can be of string type, whereas "false" operand can be of integer type.
  • String literals can be quoted by both single and double quotes (in both modes – C-style or Pascal-style). If a literal begins with a single quote, it must also end with a single quote. Double quotes may be used in single quoted string without any escaping, and vice versa. Within a string, the character used to quote the string must be escaped (the manner depends on current state of "Pascal-style string literals" parser option, see pragma). Also see predefined variable NewLine.

Data types

There are three types in ISPP: void, integer, and string. Variable of void type is declared by just specifying its name after define directive without any value. Such variables should be used with ifdef directive or Defined function.

If "allow undeclared identifiers" parser option is off (the default state, see pragma), an error is raised when undefined variable is mentioned. Otherwise, it will be treated as a value of type void.

Void is compatible with integer and string in expressions. For example, you can use addition operator with void and integer operands, in this case void operand will be treated as zero. In conjunction with string, void operand is treated as an empty string.

Comments

Comments may be embedded in an expression by using a slash and an asterisk. For example:

#emit Var1 /* this is a comment */ + Var2 /* this is also a comment */

Comments may also be placed at the end of an expression by using a semicolon or two slashes. For example:

#emit Var1 + Var2 ; this is a comment
#emit Var1 + Var2 // this is also comment

Please note that line spanning feature is triggered before any further processing, so this is also a valid comment:

#emit Var1 + Var2 ; this is \
  still a comment

Comments may also be placed anywhere by starting a line with two slashes. For example:

// This is a comment

All of the comments listed above are not included in the preprocessor output, unlike (non ISPP) comments using a semicolon at the start of a line. For example:

#emit Var1 + Var2 ; this comment is not included
// This comment is not included
; This comment IS included

Extended User Defined Function Call Syntax

In ISPP, it is possible to use named parameters when calling user defined function. Given the declaration:

#define MyFunction(int A = 2, int B = 2) A + B

This function can be called specifying parameter names:

#emit MyFunction(A = 5, B = 10)
#emit MyFunction(B = 3)
#emit MyFunction(B = 10, A = 5)

  • If a name is specified for one parameter, then all (required) parameters in the list must also be named.
  • The order of named parameters does not matter.

  • Because of this extension, an assignment expression must be enclosed in parentheses, if not using extended call syntax, to avoid ambiguity:

    #emit MyFunction((MyVar = 5), 10)

    In the above example, the equality sign is treated as a direct assignment operator.

    Although functions do not have named parameters, it is still required to enclose assignment expressions in parentheses when calling those functions.

  • By standard rule, comma is used to separate actual parameters. If you need to use sequential evaluation operator, you must include the expression in parentheses:

    #emit MyFunction((SaveToFile("script.txt"), 5), 10)

    In the above example, the first comma is treated as the sequential evaluation operator, whereas the second one as the parameter delimiter.


Inno Setup Preprocessor: Predefined Variables

There are a number of predefined variables provided ISPP:

__COUNTER__ | int. Automatically increments each time it is used (afterwards).
__FILE__ | str. Returns the name of the current file. Empty string for the root file.
__INCLUDE__ | str. Returns the current include path (or paths delimited with semicolons) set via #pragma include.
__LINE__ | int. Returns the number of the line in the current file.
__OPT_X__ | void. Defined if specified option set via #pragma option -x+ is in effect. In place of "X" may be any letter from "A" to "Z." Use Defined function to test whether the variable is defined.
__PATHFILENAME__ | str. Similar to __FILE__, but returns the full pathname of the file. Empty string for the root file.
__POPT_X__ | void. Defined if specified parser option set via #pragma parseroption -x+ is in effect. In place of "X" may be any letter from "A" to "Z." Use Defined function to test whether the variable is defined.
__WIN32__ | void. Always defined.
ISPP_INVOKED | void. Always defined.
ISPPCC_INVOKED | void. Defined if compilation was invoked using the console-mode compiler, ISCC.exe.
PREPROCVER | int. Returns the 32-bit encoded version of ISPP. Highest byte holds the major version, lowest byte holds the build number.
WINDOWS | void. Always defined.
UNICODE | void. Always defined.
CompilerPath | str. Points to the directory where the compiler is located.
SourcePath | str. Points to the directory where the current script is located, or the My Documents directory if the script has not yet been saved.
Ver | int. Returns the 32-bit encoded version of Inno Setup compiler. Highest byte holds the major version, lowest byte the minor version.
NewLine | str. Returns the newline character. Declared in ISPPBuiltins.iss.
Tab | str. Returns the tab character. Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: Line Spanning

By ending lines with ISPP's line spanning symbol preceded with a space, you can split long lines. For example:

#define MyAppName \
  "My Program"

The default line spanning symbol is "\" which can be changed using pragma.


Inno Setup Preprocessor: Visibility of Identifiers

Variables (as well as user defined functions, read "variable or user defined function" anywhere it says "variable" below) can be explicitly defined as "public," "protected," or "private." To define such a variable, its name in its define directive should be prepended with one of the visibility keywords:

#define public MyVar 12
#define protected MyVar 13
#define private MyVar 14

In the example above, none of the last two declarations undefine any of the previous, though they share the same identifier (MyVar). This is because they are declared in different visibilities.

Public variables are ordinary variables accessible from anywhere after the point they are declared.

Protected variables are accessible only in the file they are declared in and in files included by that file via include or file directives. You can basically think of them as public variables which are automatically undefined once their file has finished.

Private variables are accessible only in the file they are declared in. They are not propagated to any other file, be it included or "parent" file.

Since ISPP does not have semantics of pushing and popping variable value, visibility resolution can be useful.

Note that you cannot explicitly refer to a variable in a specific visibility from expressions. Given the example above, if MyVar is mentioned in expression in declaration file, its identifier refers to private MyVar. If it is mentioned in included file, it refers to protected MyVar. If it is mentioned in one of the files above the declaration file on the include stack (i. e. one of the files from which a chain of include directives resulted in processing the declaration file), it refers to public MyVar.

Also note, that if we'd swap last two declarations from the above example, private MyVar would become inaccessible (until protected is undefined) because protected would be declared after it and would take precedence. But it wouldn't undefine its private counterpart.

Each file can set a default visibility, the visibility that will be used when no resolution clause is specified in variable declaration. This can be done using define directive, for example:

#define protected

sets protected visibility by default.

The default visibility isn't used when evaluating expressions, it is only used when a variable is defined or undefined without explicitly specifying its visibility. When default visibility is not set, public is assumed by default. Setting default visibility is not propagated on included or parent files.

In user defined function expressions, avoid using identifiers of lower visibility than the one the user defined function is declared in. This may cause "Undeclared identifier" errors if the user defined function is called from another file.

It is recommended that you use appropriate visibility when declaring variables to avoid problems with unexpected redefinition of a variable (for example in included third-party file). If no included files depend on a variable, declare it as private. If they do, but the parent file doesn't, declare it as protected. Declare it as public otherwise. If you're unsure, then protected visibility is the common case.


Inno Setup Preprocessor: Example Script

An example script called ISPPExample1.iss is located in a separate folder. Please click the "Inno Setup Example Scripts" shortcut created in the Start Menu when you installed Inno Setup, or open the "Examples" folder in your Inno Setup directory.

Also see ISPPBuiltins.iss.


Inno Setup Preprocessor: ISPPBuiltins.iss

The ISPPBuiltins.iss file is part of Inno Setup Preprocessor and is automatically installed to root of your Inno Setup folder. This file is automatically included at the start of preprocessing: some of ISPP's functions are actually implemented by this file instead of being built-in. It also contains common declarations such as special constants. The file is a regular Inno Setup Script file so you can use all of its techniques in your own script as well.


Inno Setup Preprocessor: Command Line Compiler Execution

If Inno Setup Preprocessor is installed the console-mode compiler ISCC.exe automatically provides extra parameters to control Inno Setup Preprocessor:

/D<name>[=<value>] | Emulate #define public <name> <value>
/$<letter>(+|-) | Emulate #pragma option -<letter>(+|-)
/P<letter>(+|-) | Emulate #pragma parseroption -<letter>(+|-)
/I<paths> | Emulate #pragma include <paths>
/J<filename> | Emulate #include <filename>
/{#<string> | Emulate #pragma inlinestart <string>
/}<string> | Emulate #pragma inlineend <string>
/V<number> | Emulate #pragma verboselevel <number>

Example: iscc /$c- /Pu+ "/DLicenseFile=Trial License.txt" /Ic:\inc;d:\inc /Jdefines.iss "c:\isetup\samples\my script.iss"


Inno Setup Preprocessor: AddBackslash

Prototype

str AddBackslash(str S)

Description

Appends a backslash to the string, if it's not already there, and returns the result.

Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: AddQuotes

Prototype

str AddQuotes(str S)

Description

Adds a quote (") character to the left and right sides of the string if the string contains a space and it didn't have quotes already. This is primarily used when spawning another process with a long filename as one of the parameters.


Inno Setup Preprocessor: #append

Syntax

append-directive: append

Description

Resets the insertion point (if previously changed using insert) to the end of the preprocessor output.

See also

insert.


Inno Setup Preprocessor: ChangeFileExt

Prototype

str ChangeFileExt(str FileName, str NewExt)

Description

Changes the extension in FileName with NewExt. NewExt must not contain period.

Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: ComparePackedVersion

Prototype

int ComparePackedVersion(int Version1, int Version2)

Description

Compares Version1 to Version2. The return value is less than 0 if Version1 is less than Version2, 0 if Version1 equals Version2, or greater than 0 if Version1 is greater than Version2.


Inno Setup Preprocessor: Copy

Prototype

str Copy(str 1, int 2, int? 3)

Description

Extracts a substring from a string (first parameter). The 1-based index of the character from which the substring should start is specified by the second parameter. The third parameter specifies the number of characters to take, if it is omitted, all characters up to the end of the string are copied to the result.


Inno Setup Preprocessor: CopyFile

Prototype

void CopyFile(str 1, str 2)

Description

Copies an existing file (first parameter) to a new file (second parameter). If the new file already exists, it will be overwritten.


Inno Setup Preprocessor: Current preprocessor output

Current preprocessor output refers to the preprocessor output up to the line which ISPP is currently processing.


Inno Setup Preprocessor: DecodeVer

Prototype

str DecodeVer(int Version, int Digits = 3)

Description

Returns given 32 bit integer encoded version decoded to its string representation. The Digits parameter indicates how many elements to show (if the fourth element is 0, it won't be shown anyway).

Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: #define

Syntax

define-directive: | <variable-definition>
 | <macro-definition>
 | <default-visibility-set>
variable-definition: (define | :) [private | protected | public] <ident> [[ <expr> ]] [[=] <expr>]
macro-definition: (define | :) [private | protected | public] <ident> ( [<formal-macro-args>] ) <expr>
default-visibility-set: (define | :) private | protected | public
formal-macro-args: <formal-macro-arg> [, <formal-macro-arg>]...
formal-macro-arg: <by-val-arg> | <by-ref-arg>
by-val-arg: [<type-id>] <ident> [= <expr>]
by-ref-arg: [<type-id>] * <ident>
type-id: any | int | str | func

Description

The first syntax ("variable-definition") defines a variable named ident, or assigns a value to an element of an array named ident (use dim instead of define to define the array variable itself). If none of the public, protected, or private keywords are specified, default visibility is assumed.

The second syntax ("macro-definition") defines a user defined function named ident. When defining a user defined function there must be no whitespace between the name and opening parenthesis, otherwise it will be treated as variable declaration.

The third syntax ("default-visibility-set") sets the default visibility of further variable and user defined function definitions in this file. If no visibility declaration occurs in a file, public visibility is assumed by default.

Examples

#define MyAppName "My Program"
#define MyAppExe MyAppName + ".exe"
#define MyAppVer GetVersionNumbersString(MyAppExe)
#define MyArray[0] 15
#define Multiply(int A, int B = 10) A * B

See also

dim, undef, Visibility of Identifiers.

User Defined Functions.


Inno Setup Preprocessor: Defined

Prototype

int Defined(<ident>)
int Defined <ident>

Description

Special function. Returns non-zero if the specified identifier is defined with define directive.

Using parentheses is optional.


Inno Setup Preprocessor: Delete

Prototype

void Delete(str *S, int Index, int Count = MaxInt)

Description

Deletes the specified number of characters beginning with Index from S. S is passed by reference (therefore is modified).

Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: DeleteFile

Prototype

void DeleteFile(str)

Description

Marks the specified file for deletion after the compilation has completed. Does not return anything. Also see DeleteFileNow.


Inno Setup Preprocessor: DeleteFileNow

Prototype

void DeleteFileNow(str)

Description

Deletes the specified file. Does not return anything. Also see DeleteFile.


Inno Setup Preprocessor: #dim, #redim

Syntax

dim-directive: dim [private | protected | public] <ident> [ <expr> ] [{ <expr> [, <expr>]... }]
redim-directive: redim [private | protected | public] <ident> [ <expr> ]

Description

Use dim to define an array variable, set its dimension and optionally intialize it. All unitialized elements of the array are initialized to null (void). To assign an element value after declaring the array, use define. Instead of assigning element values with define, it is also possible to set an element value by using it as the left operand of an assignment.

Use redim to increase or decrease the dimension of an existing array variable. All new elements of the array are initialized to null (void) and existing elements are left unchanged. Identical to dim if ident isn't an existing array variable.

Examples

#dim MyArray[10]
#define MyArray[0] 15
#redim MyArray[20]
#define MyArray[10] 30
#redim MyArray[10]
#dim MyArray2[3] {1, 2, 3}

See also

define, undef, DimOf, Visibility of Identifiers.


Inno Setup Preprocessor: DimOf

Prototype

int DimOf(<ident>)
int DimOf <ident>

Description

Special function. Returns the dimension of the specified identifier.

Using parentheses is optional.

See also

dim, redim.


Inno Setup Preprocessor: DirExists

Prototype

int DirExists(str)

Description

Returns non-zero value if the specified directory exists.


Inno Setup Preprocessor: #emit

Syntax

emit-directive: (emit | =) <expr>

Description

Replaces the directive with the value of expr.

When used inline, the name of this directive can be omitted unless expr begins with the name of another directive.

Examples

[Files]
#emit 'Source: "file1.ext"; DestDir: ' + MyDestDir
Source: "file2.ext"; DestDir: {#MyDestDir}
#emit GenerateVisualCppFilesEntries ; user defined function

[Code]
const
  AppName = '{#SetupSetting("AppName")}';

See also

expr.


Inno Setup Preprocessor: EncodeVer

Prototype

int EncodeVer(int Major, int Minor, int Revision = 0, int Build = -1)

Description

Returns given four version elements encoded to a 32 bit integer number (8 bits for each element, i.e. elements must be within 0...255 range).

Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: EntryCount

Prototype

int EntryCount(str)

Description

Returns the total number of entries in specified section in current preprocessor output. It does not count empty lines or comments. Function takes care of multiple sections with the same name and counts all of them.


Inno Setup Preprocessor: #error

Syntax

error-directive: error <text>

Description

Causes the Inno Setup compiler to issue an error message with the specified text. Unlike pragma error, text in error directive is not parsed, so it is recommended to use this directive instead of pragma when possible to avoid possible syntax errors that may hide real errors your script is trying to report.

Examples

#if VER < EncodeVer(5,4,2)
  #error A more recent version of Inno Setup is required to compile this script (5.4.2 or newer)
#endif

See also

pragma, if, Error.


Inno Setup Preprocessor: Error

Prototype

void Error(str S)

Description

Functional version of error.


Inno Setup Preprocessor: Exec

Prototype

int Exec(str Filename, str? Params, str? WorkingDir, int? Wait, int? ShowCmd)

Description

Executes specified executable or batch file.

The Filename parameter specifies the filename of the executable or batch file. If this does not includes quotes then the function will add them automatically. If you have a single string containing both a filename and parameters (e.g. a command line obtained from an UninstallString registry value), you need not separate them yourself; just pass '>' in this parameter, and the full command line in the Params parameter. (Note that when this is done, the function's special platform-independent support for .bat and .cmd files is disabled; it simply passes the specified command line to CreateProcess without any processing.)

The Params parameter may be used to specify parameters for the process.

The WorkingDir parameter may be used to specify the working directory of the process. If this is omitted or empty it will try to extract a pathname from the Filename parameter and use that as the initial current directory for the process.

The Wait parameter may be set to zero if you don't wish to wait for the process to finish, and non-zero otherwise. By default, non-zero value is assumed.

The ShowCmd parameter may be any of the SW_* constants defined in ISPPBuiltins.iss. Console programs are always hidden and the ShowCmd parameter only affects GUI programs, so always using SW_SHOWNORMAL (the default) instead of SW_HIDE is recommended.

If the Wait parameter is omitted or is non-zero, the function returns the exit code of the process. Otherwise, the function result indicates whether the process has been successfully launched (non-zero for success).

Note: compared to Pascal Scripting's Exec the Wait and ShowCmd parameters are swapped!

See also

ExecAndGetFirstLine


Inno Setup Preprocessor: ExecAndGetFirstLine

Prototype

str ExecAndGetFirstLine(str Filename, str? Params, str? WorkingDir)

Description

Executes specified executable or batch file and reads the first non-empty line from its output.

The Filename parameter specifies the filename of the executable or batch file. If this does not includes quotes then the function will add them automatically. If you have a single string containing both a filename and parameters (e.g. a command line obtained from an UninstallString registry value), you need not separate them yourself; just pass '>' in this parameter, and the full command line in the Params parameter. (Note that when this is done, the function's special platform-independent support for .bat and .cmd files is disabled; it simply passes the specified command line to CreateProcess without any processing.)

The Params parameter may be used to specify parameters for the process.

The WorkingDir parameter may be used to specify the working directory of the process. If this is omitted or empty it will try to extract a pathname from the Filename parameter and use that as the initial current directory for the process.

See also

Exec


Inno Setup Preprocessor: #expr

Syntax

expr-directive: (expr | !) <expr>

Description

Evaluates an expression ignoring its result. This directive acts like emit with the exception that it doesn't emit anything to the preprocessor output.

This directive is intended to be used with functions that produce side effects and do not return any significant value.

Examples

#expr SaveToFile(AddBackslash(SourcePath) + "Preprocessed.iss"), Exec(AddBackslash(CompilerPath) + "Compil32.exe", """" + AddBackslash(SourcePath) + "Preprocessed.iss""")

See also

emit.


Inno Setup Preprocessor: ExtractFileDir

Prototype

str ExtractFileDir(str PathName)

Description

Returns the directory portion of the given filename without a backslash (unless it is a root directory). If PathName doesn't contain a directory portion, the result is an empty string.

Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: ExtractFileExt

Prototype

str ExtractFileExt(str PathName)

Description

Returns the extension portion of the given filename, NOT including the period character.

Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: ExtractFileName

Prototype

str ExtractFileName(str PathName)

Description

Returns the name portion of the given filename. If PathName ends with a backslash, the result is an empty string.

Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: ExtractFilePath

Prototype

str ExtractFilePath(str PathName)

Description

Returns the directory portion of the given filename with a backslash. If PathName doesn't contain a directory portion, the result is an empty string.

Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: #file

Syntax

file-directive: file <expr>

Description

Replaces the directive with the name of a temporary file containing the preprocessor output of the specified file. Upon end of compilation, the temporary file is automatically deleted. If an Unicode file is used, it must be UTF-8 (with or without a BOM) encoded.

Including a file using this directive creates a new independent instance of the preprocessor, passing it options currently in effect and all declared identifiers. If the included file modifies options in some way, they are not propagated back.

When using this directive in Inno Setup's Source parameter of the [Files] section, specify a DestName parameter too, else the file with not be installed with the original name.

This directive can only be used inline.

Examples

[Setup]
LicenseFile={#file "mylic.txt"}

See also

include.


Inno Setup Preprocessor: FileClose

Prototype

void FileClose(int)

Description

Closes a file opened using FileOpen. After calling FileClose, the file handle becomes invalid.

Note: opened files which are not closed using this function will be automatically closed after the script has been preprocessed.


Inno Setup Preprocessor: FileEof

Prototype

int FileEof(int)

Description

Returns zero if the file pointer does not point to the end of the file, or non-zero otherwise. If this function returns non-zero value, subsequent calls to FileRead will fail. The only parameter should be the file handle returned by FileOpen.


Inno Setup Preprocessor: FileExists

Prototype

int FileExists(str)

Description

Returns non-zero value if the specified file exists.


Inno Setup Preprocessor: FileOpen

Prototype

int FileOpen(str)

Description

Opens a text file for reading and returns the file handle (or zero on failure) to be used in subsequent calls to File* functions.


Inno Setup Preprocessor: FileRead

Prototype

str FileRead(int)

Description

Reads the next line in a text file opened with FileOpen. The only parameter should be the file handle returned by FileOpen.

Example

#define FileHandle
#define FileLine
#sub ProcessFileLine
  #define FileLine = FileRead(FileHandle)
  #pragma message FileLine
#endsub
#for {FileHandle = FileOpen("c:\autoexec.bat"); \
  FileHandle && !FileEof(FileHandle); ""} \
  ProcessFileLine
#if FileHandle
  #expr FileClose(FileHandle)
#endif

See also

define, sub, pragma, for, if.


Inno Setup Preprocessor: FileReset

Prototype

void FileReset(int)

Description

Resets the file pointer to zero, so the subsequent call to FileRead will read the first line of the file. The only parameter should be the file handle returned by FileOpen.


Inno Setup Preprocessor: FileSize

Prototype

int FileSize(str)

Description

Returns size, in bytes, of the specified file. If the file does not exist, the result is -1.


Inno Setup Preprocessor: Find

Prototype

int Find(int 1, str 2, int? 3, str? 4, int? 5, str? 6, int? 7)

Description

Intended to be used with insert directive: returns the index of the line in the preprocessor output depending on specified criteria.

First parameter denotes the index of the line to start the search from, usually it is set to zero.

Second, fourth, and sixth parameters should specify string(s) to search within each line. Only the second parameter must be specified, whereas fourth and sixth may be omitted.

Third, fifth, and seventh parameters should specify the search flags for each string meaning that third parameter specifies flags for second, fifth for fourth, and seventh for sixth.

If any of the 'flags' parameters is omitted but the string parameter preceding it is specified, FIND_MATCH | FIND_AND (i. e. 0) is assumed.

Values for third, fifth, and seventh parameters of Find function are declared in ISPPBuiltins.iss. See Find flags topic for the description of each value.

See also

insert.

  • Find flags


Inno Setup Preprocessor: Find flags

Description

One of the following four values must be specified:

FIND_MATCH (0) means that the line must match the search string.

FIND_BEGINS (1) means that the line must start with the search string.

FIND_ENDS (2) means that the line must end with the search string.

FIND_CONTAINS (3) means that the line must contain (i. e. it also can match, begin, or end with) the search string.

Any of the following modifiers may be combined with one of the previous using bitwise OR operator (|):

FIND_CASESENSITIVE (4) means that comparison must be case-sensitive.

FIND_AND (0) means that this criterium (the pair of parameters in Find function) must be met as well as previous criteria.

FIND_OR (8) means that it is allowed that this criterium is tested even if previous criteria were not met.

FIND_NOT (16) means that this criterium must not be met.

FIND_AND and FIND_OR are mutually exclusive. If both are specified, FIND_OR takes precedence.

Special flags:

FIND_TRIM (32) means that leading and trailing whitespaces must be stripped off from the line prior to testing it against all the criteria. This flag can only be used in the third parameter of the Find function. It is not mutually exclusive with any of the previously mentioned flags.


Inno Setup Preprocessor: FindClose

Prototype

void FindClose(int)

Description

Terminates a FindFirst/FindNext sequence. The parameter must be a non-zero find handle returned by FindFirst.

This function is obsolete since 1.2. ISPP automatically frees resources allocated in a call to FindFirst.


Inno Setup Preprocessor: FindCode

Prototype

int FindCode()

Description

Returns the index of the line following either the [Code] section header, or the "program" keyword, if any.

Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: FindFirst

Prototype

int FindFirst(str, int)

Description

Searches the directory specified by first parameter for the first file that matches the file name implied by first parameter and the attributes specified by second parameter. If the file is found, the result is a find handle, that should be used in subsequent calls to FindGetFileName, FindNext, and FindClose functions, otherwise the return value is 0.

The first parameter is the directory and file name mask, including wildcard characters. For example, '.\*.*' specifies all files in the current directory).

The second parameter specifies the special files to include in addition to all normal files. Choose from these file attribute constants defined in ISPPBuiltins.iss when specifying this parameter:

faReadOnly | Read-only files
faHidden | Hidden files
faSysFile | System files
faVolumeID | Volume ID files
faDirectory | Directory files
faArchive | Archive files
faAnyFile | Any file

Attributes can be combined by OR-ing their constants or values. For example, to search for read-only and hidden files in addition to normal files, pass faReadOnly | faHidden as the parameter.

Example

[Files]
#define FindHandle
#define FindResult
#define Mask "*.pas"

#sub ProcessFoundFile
  #define FileName FindGetFileName(FindHandle)
  #if LowerCase(Copy(FileName, 1, 4)) == "ispp"
    Source: {#FileName}; DestDir: {app}\ispp
  #else
    Source: {#FileName}; DestDir: {app}
  #endif
#endsub

#for {FindHandle = FindResult = FindFirst(Mask, 0); FindResult; FindResult = FindNext(FindHandle)} ProcessFoundFile
#if FindHandle
  #expr FindClose(FindHandle)
#endif

See also

define, sub, if.


Inno Setup Preprocessor: FindGetFileName

Prototype

str FindGetFileName(int)

Description

Feed FindGetFileName with the find handle returned by FindFirst to get the name of the file found by the last call to FindFirst or FindNext.


Inno Setup Preprocessor: FindNext

Prototype

int FindNext(int)

Description

Returns the next entry that matches the name and attributes specified in a previous call to FindFirst. The parameter must be a find handle returned by FindFirst. The return value is non-zero if the function was successful.


Inno Setup Preprocessor: FindSection

Prototype

int FindSection(str Section = "Files")

Description

Returns the index of the line following the header of the section. This function is intended to be used with insert directive.

Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: FindSectionEnd

Prototype

int FindSectionEnd(str Section = "Files")

Description

Returns the index of the line following last entry of the section. This function is intended to be used with #insert directive.

Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: #for

Syntax

for-directive: for { <expr1> ; <expr2> ; <expr3> } <expr4>

Description

Use the for directive to get loop behaviour. for takes 4 expressions. The first expression (expr1) is called "initialization expression," the second expression (expr2) "condition," the third expression (expr3) "action," and the final expression (expr4) "loop body."

The logic the for directive follows is:

1. The initialization expression is evaluated.

2. The condition is evaluated. If it evaluates to 0, the loop ends.

3. The loop body is evaluated.

4. The action is evaluated.

5. Process repeats from 2.

Examples

// Call AddFile user defined procedure 200 times
#for {i = 200; i > 0; i--} AddFile

More examples

FindFirst, FileRead.

See also

sub, include.


Inno Setup Preprocessor: ForceDirectories

Prototype

int ForceDirectories(str)

Description

Creates all the directories along the specified directory path all at once. If the first directories in the path do exist, but the latter ones don't, ForceDirectories creates just the ones that don't exist. Returns non-zero value if successful.


Inno Setup Preprocessor: GetDateTimeString

Prototype

str GetDateTimeString(str, str, str)

Description

Returns the current date and time as a string using the specified formatting.

The first parameter is the format string. The second and third parameters denote the DateSeparator and TimeSeparator parameters explained below.

The following format specifiers are supported:

d | Displays the day as a number without a leading zero (1-31).
dd | Displays the day as a number with a leading zero (01-31).
ddd | Displays the day as an abbreviation (Sun-Sat).
dddd | Displays the day as a full name (Sunday-Saturday).
ddddd | Displays the date using the system's short date format.
dddddd | Displays the date using the system's long date format.
m | Displays the month as a number without a leading zero (1-12). If the m specifier immediately follows an h or hh specifier, the minute rather than the month is displayed.
mm | Displays the month as a number with a leading zero (01-12). If the mm specifier immediately follows an h or hh specifier, the minute rather than the month is displayed.
mmm | Displays the month as an abbreviation (Jan-Dec).
mmmm | Displays the month as a full name (January-December).
yy | Displays the year as a two-digit number (00-99).
yyyy | Displays the year as a four-digit number (0000-9999).
h | Displays the hour without a leading zero (0-23).
hh | Displays the hour with a leading zero (00-23).
n | Displays the minute without a leading zero (0-59).
nn | Displays the minute with a leading zero (00-59).
s | Displays the second without a leading zero (0-59).
ss | Displays the second with a leading zero (00-59).
t | Displays the time using the system's short time format.
tt | Displays the time using the system's long time format.
am/pm | Uses the 12-hour clock for the preceding h or hh specifier. Displays 'am' for any hour before noon, and 'pm' for any hour after noon. The am/pm specifier can use lower, upper, or mixed case, and the result is displayed accordingly.
a/p | Uses the 12-hour clock for the preceding h or hh specifier. Displays 'a' for any hour before noon, and 'p' for any hour after noon. The a/p specifier can use lower, upper, or mixed case, and the result is displayed accordingly.
/ | Displays the date separator character given by the DateSeparator parameter. If DateSeparator is set to an empty string, the system's date separator character will be used instead.
: | Displays the time separator character given by the TimeSeparator parameter. If TimeSeparator is set to an empty string, the system's time separator character will be used instead.
'xx'/"xx" | Characters enclosed in single or double quotes are displayed as-is, and do not affect formatting.

Format specifiers may be written in upper case as well as in lower case letters--both produce the same result.

Example

#define MyDateTimeString GetDateTimeString('ddddd', '', '')
#define MyDateTimeString GetDateTimeString('ddddd tt', '', '')
#define MyDateTimeString GetDateTimeString('dd/mm/yyyy hh:nn:ss', '-', ':')


Inno Setup Preprocessor: GetEnv

Prototype

str GetEnv(str)

Description

Returns the value of the environment variable whose name is specified as the parameter. Returns an empty string if the variable is not defined.


Inno Setup Preprocessor: GetFileDateTimeString

Prototype

str GetFileDateTimeString(str, str, str, str)

Description

Returns the date and time of the specified file as a string using the specified formatting.

The first parameter is the file name. The second, third and fourth parameters denote the format string, DateSeparator and TimeSeparator parameters as explained in the GetDateTimeString topic.

Example

#define MyFileDateTimeString GetFileDateTimeString('myfile.txt', 'dd/mm/yyyy hh:nn:ss', '-', ':');


Inno Setup Preprocessor: GetMD5OfFile

Prototype

str GetMD5OfFile(str)

Description

Gets the MD5 sum of the specified file, as a string.


Inno Setup Preprocessor: GetMD5OfString

Prototype

str GetMD5OfString(str)

Description

Gets the MD5 sum of the specified ANSI string, as a string.

Example

#define MD5 GetMD5OfString('Test')
// MD5 = '0cbc6611f5540bd0809a388dc95a615b'


Inno Setup Preprocessor: GetMD5OfUnicodeString

Prototype

str GetMD5OfString(str)

Description

Gets the MD5 sum of the specified Unicode string, as a string.

Causes an internal error if called during non Unicode compilation.

Example

#define MD5 GetMD5OfUnicodeString('Test')
// MD5 = '8e06915d5f5d4f8754f51892d884c477'


Inno Setup Preprocessor: GetPackedVersion

Prototype

str GetPackedVersion(str Filename, int *Version)

Description

Gets the packed version of the specified file. Returns the version as a string (in "0.0.0.0" format) if successful, an empty string otherwise.

Always use ComparePackedVersion or SamePackedVersion to compare packed versions.

Declared in ISPPBuiltins.iss.

See also

PackVersionComponents


Inno Setup Preprocessor: GetSHA1OfFile

Prototype

str GetSHA1OfFile(str)

Description

Gets the SHA-1 hash of the specified file, as a string.


Inno Setup Preprocessor: GetSHA1OfString

Prototype

str GetSHA1OfString(str)

Description

Gets the SHA-1 hash of the specified ANSI string, as a string.


Inno Setup Preprocessor: GetSHA1OfUnicodeString

Prototype

str GetSHA1OfString(str)

Description

Gets the SHA-1 hash of the specified Unicode string, as a string.

Causes an internal error if called during non Unicode compilation.


Inno Setup Preprocessor: GetStringFileInfo

Prototype

str GetStringFileInfo(str 1, str 2, int? 3)

Description

Retrieves string from specified file's (first parameter) version information resource.

Second parameter is the name of the version info string-value. This should be one of the predefined strings. Those strings and shortcuts are declared in ISPPBuiltins.iss.

Third optional parameter should specify the language and charset identifier. For example: 0x04BE0409 stands for "English (United States)." If this parameter is omitted, ISPP scans for all available version info blocks to find the value.

The function returns an empty string, if it was unable to retrieve the desired string-value.


Inno Setup Preprocessor: GetVersionComponents

Prototype

str GetVersionComponents(str Filename, int *Major, int *Minor, int *Revision, int *Build)

Description

Gets the individual version components of the specified file. Returns the version as a string (in "0.0.0.0" format) if successful, an empty string otherwise.

Declared in ISPPBuiltins.iss.

See also

PackVersionComponents


Inno Setup Preprocessor: GetVersionNumbers

Prototype

str GetVersionNumbers(str Filename, int *VersionMS, int *VersionLS)

Description

Gets the version numbers of the specified file. Returns the version as a string (in "0.0.0.0" format) if successful, an empty string otherwise.

Declared in ISPPBuiltins.iss.

See also

PackVersionNumbers


Inno Setup Preprocessor: GetVersionNumbersString

Prototype

str GetVersionNumbersString(str Filename)

Description

Returns the version of the specified file as a string (in "0.0.0.0" format) if successful, an empty string otherwise.

Also see GetStringFileInfo, which can also be used to retrieve file versions using "FileVersion" or "ProductVersion" as the second parameter. The difference is that GetVersionNumbersString takes it from the fixed block of version info, unlike GetStringFileInfo which extracts string from the language specific block.


Inno Setup Preprocessor: #if, #elif, #else, #endif

Syntax

if-directive: if <expr>
elif-directive: elif <expr>
else-directive: else
endif-directive: endif

Description

The if, elif, else, and endif conditional directives control in- and exclusion of portions of script.

ISPP first evaluates the expressions following each if or elif directive until it finds one evaluating to non-zero. It then selects the portion of script following this directive up to its associated elif, else, or endif. Earlier portions which followed an if or elif which evaluated to zero, or which follows any next elif are not selected and thus not seen by the Inno Setup compiler.

If no expression evaluated to non-zero, the preprocessor selects the script portion after the else directive if present, otherwise nothing is selected.

Finally, after selecting any script portion, ISPP preprocesses it too, so if it contains other preprocessor directives, ISPP carries out those directives as well.

Each if directive in a source file must be matched by a closing endif directive. Any number of elif directives can appear between the if and endif directives, but at most one else directive is allowed. The else directive, if present, must be the last directive before endif.

The if, elif, else, and endif directives can be nested. Each nested else, elif, or endif directive belongs to the closest preceding if directive.

Inline conditional directives may not be mixed with simple. If the if directive is simple (occupying a whole line), its associated directives (elif, else, or endif) must also be simple and not inline (appearing inside other lines).

Examples

#define Lang

[Tasks]
#if "English" == Lang = ReadIni(SetupSetting("MessagesFile"), \
  "LangOptions", "LanguageName")
  Description: "For all users"; Name: all
#elif "German" == Lang
  Description: "Fur alle"; Name: all
#else
# error Unsupported language
#endif


Inno Setup Preprocessor: #ifdef, #ifndef, #ifexist, #ifnexist

Syntax

ifdef-directive: ifdef <ident>
ifndef-directive: ifndef <ident>
ifexist-directive: ifexist <expr>
ifnexist-directive: ifnexist <expr>

Description

You can use the ifdef, ifndef, ifexist, and ifnexist directives anywhere if can be used. The ifdef identifier statement is equivalent to if 1 when the specified identifier has been defined, and equivalent to if 0 when the identifier has not been defined or has been undefined with the undef directive. These directives check only for the presence or absence of identifiers defined with define.

ifexist and ifnexist directives check for presence and absence of the file, respectively.

Examples

[Files]
#ifexist "myfile.ext"
  Filename: "myfile.ext"; DestDir: {app}
#endif
#ifdef Enterpise
  Filename: "extra.dll"; DestDir: {app}
#endif

See also

FileExists


Inno Setup Preprocessor: #include

Syntax

include-directive: | (include | +) < <filename> >
 | (include | +) <expr>

Description

Includes the preprocessor output of the specified file. If an Unicode file is used, it must be UTF-8 (with or without a BOM) encoded

If the filename is enclosed in quotes, ISPP first searches for the file in the directory where current file resides, then in the directory where the file that included current file resides, and so on. If the file is not found, it is searched on current include path, set via pragma, then on the path specified by INCLUDE environment variable.

If filename is an expression or specified in angle brackets, it is searched on current include path only.

The filename may be prefixed by "compiler:", in which case it looks for the file in the Compiler directory.

This directive cannot be used inline.

Examples

#include <file.iss>
#include "c:\dir\file.iss"
#include AddBackslash(CompilerPath) + "common.iss"

See also

file, sub.


Inno Setup Preprocessor: #insert

Syntax

insert-directive: insert <expr>

Description

Changes the insertion point. By default, each processed line is added to the end of the preprocessor output. Using insert the point at which the next processed line will be added to the preprocessor output can be changed. insert takes an expression which must evaluate to an integer. The insertion point will be set to this integer.

The insertion point is also always automatically incremented each time after a line has been added to the preprocessor output, so that each new line is inserted after the one previously inserted.

It is not recommended to use script generating functions (such as SetSetupSetting) which may insert a line by themselves, thus shifting a part of the preprocessor output one line down, whereas insertion point is not updated. This may result in different insertion point than expected.

The Find function can be used to produce values for the insert directive.

Examples

#insert FindSectionEnd("Icons")
#insert FindSection("Setup") + 1
#insert Find(0, "somefile.ext", FIND_CONTAINS)

See also

append.


Inno Setup Preprocessor: Insert

Prototype

void Insert(str *S, int Index, str Substr)

Description

Inserts specified Substr at Index'th character into S. S is passed by reference (therefore is modified).

Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: Int

Prototype

int Int(any 1, int? 2)

Description

Converts an expression (first parameter) to its integer representation. If the expression is an integer, the result of the function is the expression value. If the expression is void, the result is 0. If the expression is string, ISPP tries to convert it to integer; if such attempt fails, an error is raised unless second parameter specifies the default result.


Inno Setup Preprocessor: IsWin64

Prototype

int IsWin64()

Description

Returns non-zero if the system is running a 64-bit version of Windows that provides the API support Inno Setup requires to perform 64-bit installation tasks, or zero otherwise.


Inno Setup Preprocessor: Len

Prototype

int Len(str)

Description

Returns the length of the given string.


Inno Setup Preprocessor: LowerCase

Prototype

str LowerCase(str)

Description

Returns a string with the same text as the string passed in its parameter, but with all letters converted to lowercase. The conversion affects only 7-bit ASCII characters between 'A' and 'Z'.


Inno Setup Preprocessor: Max

Prototype

int Max(int A, int B, int C = MinInt)

Description

Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: Message

Prototype

void Message(str S)

Description

Functional version of pragma message.


Inno Setup Preprocessor: Min

Prototype

int Min(int A, int B, int C = MaxInt)

Description

Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: PackVersionComponents

Prototype

int PackVersionComponents(int Major, int Minor, int Revision, int Build)

Description

Packs individual version components into a single value.

Always use ComparePackedVersion or SamePackedVersion to compare packed versions.

Declared in ISPPBuiltins.iss.

See also

GetVersionComponents, PackVersionNumbers, UnpackVersionComponents


Inno Setup Preprocessor: PackVersionNumbers

Prototype

int PackVersionNumbers(int VersionMS, int VersionLS)

Description

Packs version numbers into a single value.

Always use ComparePackedVersion or SamePackedVersion to compare packed versions.

Declared in ISPPBuiltins.iss.

See also

GetVersionNumbers, PackVersionComponents, UnpackVersionNumbers


Inno Setup Preprocessor: Pos

Prototype

int Pos(str 1, str 2)

Description

Searches for a substring (first parameter) in another string (second parameter) and returns an integer value that is the 1-based index of the first character of the substring within the second string. Pos is case-sensitive. If the substring is not found, Pos returns zero.


Inno Setup Preprocessor: Power

Prototype

int Power(int X, int P = 2)

Description

Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: #pragma

Syntax

pragma-directive: | <pragma-option>
 | <pragma-itokens>
 | <pragma-msg>
 | <pragma-verblev>
 | <pragma-include>
 | <pragma-spansymb>
pragma-option: pragma (option | parseroption) - <letter> (+ | -) [- <letter> (+ | -) ]...
pragma-itokens: pragma (inlinestart | inlineend) <expr>
pragma-msg: pragma (message | warning | error) <expr>
pragma-verblev: pragma verboselevel <expr>
pragma-include: pragma include <expr>
pragma-spansymb: pragma spansymbol <expr>

Description

pragma is a special directive. Please note that if ISPP fails to parse parameters of this directive (because of typo or wrong syntax), no error will occur – only a warning will be issued; this is done for compatibility with other preprocessors, which can have their own syntax of pragma directive.

The "pragma-option" variant of pragma directive controls the options which ISPP uses to read the source. Each option has an assigned letter and you specify options by typing group name (option or parseroption), then the letter prefixed by a dash. After the letter a plus must be used to turn the option on and minus turn it off. Multiple options can be specified at once (see syntax). The first group of options (option) controls the general options, while the second group (parseroption) controls options specific to parser. The list of options is provided at the end of this topic.

The "pragma-itokens" variant is used to specify inline directive terminators: starting and ending, respectively. After the token description keyword (inlinestart or inlineend) a string type expression must follow. It must not evaluate to an empty string. It is allowed to specify the same token for both starting and ending terminators. By default, {# (opening brace and a pound sign) and } (closing brace) are assumed.

The "pramga-msg" variant issues a message of the type specified by the keyword following the directive name. Messages and warnings are sent to the messages window of the compiler. Errors are shown (by the compiler) using message boxes. Expression must be of type string. Also see the error directive.

The "pragma-verblev" variant turns on verbose mode and sets the level of verbosity which controls the importance of messages (see below). Least important messages will show up only when highest verbose level is set.

The "pragma-include" variant sets the include path. Expression may specify multiple paths delimited with semicolons. The list of these directories is used when ISPP tries to find a file, mentioned in include directive.

The "prama-spansymb" variant sets the symbol used to span multiple lines together. Expression must not evaluate to an empty string. Only first symbol in string is taken.

ISPP options

c | Indicates that the preprocessor output should be sent to the compiler after preprocessing is done. Default state: on.
e | Specifies whether empty lines or lines with only whitespace should be emitted to the preprocessor output. Default state: on.
v | Turns on/off the verbose mode. Default state: off.

Parser options

b | Short-circuit boolean evaluation. Default state: on.
m | Short-circuit multiplication evaluation. (In "0 * A", A will not be evaluated, since the result of expression is known to be zero.) Default state: off.
p | Pascal-style string literals. In off state, uses C-style string literals (with escape sequences). Default state: on.
u | Allow undeclared identifiers. If an undefined identifier is encountered, ISPP will raise an error unless this option is turned on, in which case a standalone identifier (the one that does not look like a function call) will be considered void value. Default state: off.

Verbose levels

0 | Verbosity level messages
1 | Messages about any temporary files created by #file
2 | #insert and #append messages
4 | #dim, #define and #undef messages
6 | Conditional inclusion messages
8 | #emit messages
9 | Macro and functions call messages
10 | Local macro array allocation messages

Examples

#pragma parseroption -b- -u+
#pragma option -c-
#pragma warning "Variable value is: " + Str(MyVar)
#pragma option -v+
#pragma verboselevel 9
#pragma inlinestart "$("
#pragma inlineend ")"
#pragma include __INCLUDE__ + ";D:\INCLUDE"
#pragma spansymbol "_"

See also

Message, Warning, Error.


Inno Setup Preprocessor: ReadIni

Prototype

str ReadIni(str 1, str 2, str 3, str? 4)

Description

Reads the value from an INI file. Parameter 1 must be the name of the INI file, parameter 2 – the name of a section in the INI file, the third parameter is the key in the section to read. Last optional parameter can be used to provide the default value that will be returned on failure, if it is omitted, an empty string is returned.


Inno Setup Preprocessor: ReadReg

Prototype

any ReadReg(int 1, str 2, str? 3, any? 4)

Description

Reads the value of the specified key in the 32-bit or 64-bit system registry. First parameter is the root key, such as HKEY_LOCAL_MACHINE (32-bit) or HKEY_LOCAL_MACHINE_64 (64-bit). Constants for use with this parameter are declared in ISPPBuiltins.iss accompanying ISPP. Second parameter specifies a subkey. Third parameter specifies the name of the value, if this parameter is omitted, a default value is assumed. Last optional parameter may be used to specify the default value that will be returned on failure.

Note that this function can return a value of any type depending on the type of actual value in the registry.


Inno Setup Preprocessor: RemoveBackslash

Prototype

str RemoveBackslash(str S)

Description

Removes the trailing backslash from the string unless the string points to a root directory, and returns the result.

Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: RemoveFileExt

Prototype

void RemoveFileExt(str FileName)

Description

Removes the extension in FileName.

Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: RPos

Prototype

int RPos(str 1, str 2)

Description

Searches for a substring (first parameter) in another string (second parameter) and returns an integer value that is the 1-based index of the first character of the last occurrence of the substring within the second string. RPos is case-sensitive. If the substring is not found, RPos returns zero.


Inno Setup Preprocessor: SamePackedVersion

Prototype

int SamePackedVersion(int Version1, int Version2)

Description

Compares the packed versions Version1 and Version2 and returns True if they are equal.


Inno Setup Preprocessor: SameStr

Prototype

int SameStr(str S1, str S2)

Description

Returns True if the given strings are identical, with case-sensitivity.

Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: SameText

Prototype

int SameText(str S1, str S2)

Description

Returns True if the given strings are identical, ignoring case.

Declared in ISPPBuiltins.iss.


Inno Setup Preprocessor: SaveStringToFile

Prototype

int SaveStringToFile(str Filename, str S, int? Append, int? UTF8)

Description

Saves the specified string to the specified file. If Append is True or ommitted and the specified file already exists, it will be appended to instead of overwritten. If UTF8 is True or ommitted, the string will be saved with UTF8 encoding instead of ASCII encoding. Returns True if successful, or False otherwise.

This function does not automatically write a line break before or after the string. If Append is True or ommitted and the existing file did not end in a line break, the function will effectively append to the existing last line. To avoid this you can put line break characters (using NewLine) before and/or after your string.

Example

#expr SaveStringToFile('c:\filename.txt', NewLine + 'the string' + NewLine)


Inno Setup Preprocessor: SaveToFile

Prototype

void SaveToFile(str)

Description

Saves current preprocessor output to the specified file.


Inno Setup Preprocessor: SetSetupSetting

Prototype

void SetSetupSetting(str 1, str 2)

Description

Modifies or generates [Setup] section directive given the key (first parameter) and its value (second parameter).

If there is no [Setup] section in current preprocessor output (it may happen that function is called before that section in a script), its header (as well as directive itself) is generated by this function.

Please use this function carefully – it should not be called when ISPP is in insert mode (i. e. after insert directive).


Inno Setup Preprocessor: SetupSetting

Prototype

str SetupSetting(str)

Description

Parses [Setup] section in current preprocessor output to find the key whose name is specified as function parameter. Function returns the value of that key if it's found, or an empty string otherwise.


Inno Setup Preprocessor: Str

Prototype

str Str(any)

Description

Converts an expression to string. If the expression is integer, the result is its string representation. If the expression is void, the result is an empty string. Otherwise the result is the value of the expression.


Inno Setup Preprocessor: StringChange

Prototype

str StringChange(str, str, str)

Description

Returns a copy of the first string, with all occurrences of the second string changed to the third string.

Example

#define MyString "a ca c"
#define MyString2 StringChange(MyString, " ", "b")
// MyString2 = 'abcabc'


Inno Setup Preprocessor: StrToVersion

Prototype

int StrToVersion(str Version)

Description

Returns the specified string (in "0.0.0.0" format) as a packed version.

Declared in ISPPBuiltins.iss.

See also

VersionToStr, PackVersionNumbers, PackVersionComponents


Inno Setup Preprocessor: #sub, #endsub

Syntax

sub-directive: sub <ident>
endsub-directive: endsub

Description

sub and endsub directives are used to declare a user defined procedure which is a portion of script which may be included later once or several times. You may think of a user defined procedure as being similar to an external file, and a call to a user defined procedure as being similar to inclusion of an external file, except that procedures may also be called from within expressions. Please note that it is strongly not recommended to call procedures which emit several lines to the preprocessor output from within compound expressions or directives.

A procedure is called by simply specifying its identifier, with which it was declared.

A procedure is not processed in any way until it is called, so if any errors exist in its body, they will only pop up when the procedure is called.

Examples

#sub AddFile
  #if Copy(FileName, 1, 1) == "A"
    Source: {#FileName}; DestDir: {app}\A
  #else
    Source: {#FileName}; DestDir: {app}
  #endif
#endsub

More examples

FindFirst, FileRead.

See also

User Defined Functions, if, emit.


Inno Setup Preprocessor: Preprocessor output

Preprocessor output refers to the preprocessed version of the script.


Inno Setup Preprocessor: Trim

Prototype

str Trim(str)

Description

Returns a copy of the specified string without leading and trailing spaces.


Inno Setup Preprocessor: TypeOf

Prototype

int TypeOf(<ident>)
int TypeOf <ident>

Description

Special function. Returns one of predefined TypeOf constants which are declared in ISPPBuiltins.iss for the specified identifier.

Using parentheses is optional.


Inno Setup Preprocessor: #undef

Syntax

undef-directive: (undef | x) [private | protected | public] <ident>

Description

Undefines (removes) a variable or user defined function. If no visibility (public, protected, or private) is specified, ISPP first tries to remove a private variable of the given name, then protected, then public.

Examples

#undef MyVar
#undef MyFunction
#undef public MyVar

See also

define, dim, Visibility of Identifiers.


Inno Setup Preprocessor: UnpackVersionComponents

Prototype

void UnpackVersionComponents(int Version, int *Major, int *Minor, int *Revision, int *Build)

Description

Unpacks a packed version into individual version components.

Declared in ISPPBuiltins.iss.

See also

UnpackVersionNumbers, PackVersionComponents


Inno Setup Preprocessor: UnpackVersionNumbers

Prototype

void UnpackVersionNumbers(int Version, int *VersionMS, int *VersionLS)

Description

Unpacks a packed version into version numbers.

Declared in ISPPBuiltins.iss.

See also

UnpackVersionComponents, PackVersionNumbers


Inno Setup Preprocessor: UpperCase

Prototype

str UpperCase(str)

Description

Returns a string with the same text as the string passed in its parameter, but with all letters converted to uppercase. The conversion affects only 7-bit ASCII characters between 'A' and 'Z'.


Inno Setup Preprocessor: VersionToStr

Prototype

void VersionToStr(int Version)

Description

Returns the specified packed version as a string (in "0.0.0.0" format).

Declared in ISPPBuiltins.iss.

See also

StrToVersion, UnpackVersionNumbers, UnpackVersionComponents


Inno Setup Preprocessor: Warning

Prototype

void Warning(str S)

Description

Functional version of pragma warning.


Inno Setup Preprocessor: WriteIni

Prototype

void WriteIni(str 1, str 2, str 3, any 4)

Description

Writes specified value to an INI file. Parameter 1 is the name of the INI file, parameter 2 – the name of a section in the INI file, parameter 3 – the name of a key in the section. Last parameter should be set to the value you wish to be written to the INI file, it can be of any type.


Inno Setup Preprocessor: YesNo

Prototype

int YesNo(str S)

Description

Returns nonzero value if given string is "yes", "true" or "1". Intended to be used with the SetupSetting function.

Declared in ISPPBuiltins.iss.