Inno Setup 预处理器: 介绍

Inno Setup 预处理器 (ISPP) 是一个预加载为 Inno Setup 插件。

The main purpose of ISPP is to automate compile-time tasks and decrease the probability of typos in your scripts. For example, you can declare an ISPP variable (compile-time variable) – 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 probably need to change all occurrences of your application name throughout the script (AppName, AppVerName, DefaultGroupName etc. [Setup] section directives).

Another example of using ISPP would be gathering version information from your application by reading the version info of an EXE file, and using it in AppVerName [Setup] 段 指令或任何地方。未经 ISPP，每次版本的应用程序变更，你将不得不修改你的脚本。

通过 ISPP 有条件的编译(包含部份脚本)，因此，你的安装包可以保持只有一个脚本，就可以包含不同的版本/级别(试用和完整功能，精简和企业，等)。

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.

所有主题

  • 文档约定
  • 指令
  • 函数
  • 预定义和内部定义变量
  • Line Spanning
  • 示例脚本
  • 用户自定义宏
  • ISPPBUILTINS.ISS
  • 标识符的可见性
  • 表达式语法
  • 扩展的命令行编译器
  • Translation
  • Current translation


Inno Setup 预处理器: 文档约定

指令语法约定

指令使用语法使用以下约定。

() | 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.

函数原型文档约定

函数原型作为函数返回类型被显示, function name and list of formal arguments in parentheses.

Words int , str , any , and void are used to specify integer type, string type, any type, or null type (also referred to as nothing, void), respectively. Null type as function result means that function does not return any value.

Question mark ( ? ) after the type of an argument means that this argument is optional.


Inno Setup 预处理器: 指令

在 ISPP 里指令可以以两种方式使用：简单或内嵌的。

简单的指令，占据整行，而且首字符必须是 # 。例如下面的定义的变量称为 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} .

有效指令

  • #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 预处理器: 函数

There are a number of predefined functions provided by ISPP which you can use to perform compile-time actions and/or change your script. For example the following reads version info from an EXE and uses the return value of the function to change the script:

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

[Setup]
AppVerName=MyProg version {#MyAppVer}

有效函数

  • GetFileVersion
  • GetStringFileInfo
  • Int
  • Str
  • FileExists
  • DirExists
  • FileSize
  • ReadIni
  • WriteIni
  • ReadReg
  • Exec
  • Copy
  • Pos
  • RPos
  • Len
  • SaveToFile
  • Find
  • SetupSetting
  • SetSetupSetting
  • LowerCase
  • EntryCount
  • GetEnv
  • DeleteFile
  • CopyFile
  • FindFirst
  • FindNext
  • FindClose
  • FindGetFileName
  • FileOpen
  • FileRead
  • FileReset
  • FileEof
  • FileClose
  • GetDateTimeString
  • GetFileDateTimeString
  • GetMD5OfString
  • GetMD5OfUnicodeString
  • GetMD5OfFile
  • GetSHA1OfString
  • GetSHA1OfUnicodeString
  • GetSHA1OfFile
  • Trim
  • StringChange
  • Defined
  • TypeOf
  • DimOf
  • ParseVersion
  • EncodeVer
  • DecodeVer
  • FindSection
  • FindSectionEnd
  • FindCode
  • ExtractFilePath
  • ExtractFileExt
  • ExtractFileName
  • ChangeFileExt
  • AddBackslash
  • RemoveBackslash
  • Delete
  • Insert
  • YesNo
  • Power
  • Min
  • Max


Inno Setup 预处理器: 预定义和内部定义变量

There are a number of predefined variables provided ISPP:

__COUNTER__ | int . Automatically increments each time it is used (afterwards).
__FILE__ | str . 返回当前文件名。空字符为根文件。
__INCLUDE__ | str . 返回当前包含路径 (或用分号作为路径定义) set via #pragma include .
__LINE__ | int . Returns the number of the line in the current file (not a translation), on which the variable is used (or macro that uses this variable is called).
__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 . 总是被定义。
ISPP_INVOKED | void . 总是被定义。
PREPROCVER | int . 返回32位编码的 ISPP 版本。最高的字节拥有主要的版本，最低的字节拥有构建数字。
WINDOWS | void . 总是被定义。
UNICODE | void . ISPP的Unicode版本总是被定义。Use Defined function to test whether the variable is 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 current directory if the script has not yet been saved.
Ver | int . 返回32位编码的 Inno Setup 编译器版本。最高的字节拥有主要的版本，最低的字节通常为零。


Inno Setup 预处理器: 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 预处理器: 示例脚本

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 "示例" folder in your Inno Setup directory.

查阅 ISPPBUILTINS.ISS 文件.


Inno Setup 预处理器: 用户自定义宏

You can define so called "macros" in your scripts, these can be thought of as "user defined functions."

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

The formal syntax of macro declaration is provided in define and the ISPPBUILTINS.ISS 文件 contains many example macros.

Please note that there must be no space between macro 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 macro expression modifies by-reference parameter, the variable that is passed as this parameter gets modified. By-value parameters can also be modified by macro expression (using assignment operators), but this modification doesn't affect the value of a variable which could be passed as this parameter.

Though macro can only contain one expression, it can be used as full featured user defined function, because ISPP supports sequential evaluation operator (comma), assignment operators (simple and compound) and conditional operator ( ?: ).

查阅

  • Macros' Local array


Inno Setup 预处理器: ISPPBUILTINS.ISS

该 ISPPBUILTINS.ISS 文件是伴随着 Inno Setup 预处理器一起的。如果它存在于编译器目录，它会自动被包括，会在你的脚本中第一行用 include 指令嵌入内容。该文件包含公共声明，如特殊常数用一些内置函数，和一些有用的宏。该文件是一个有规律的 Inno Setup 脚本，但大多只含有 ISPP 指令。

要了解更多这个文件所提供的有关功能请用 Inno Setup 编译器打开，会有好的解释。


Inno Setup 预处理器: 标识符的可见性

Variables (as well as macros, read "variable or macro" anywhere it says "variable" below) can be explicitily 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 explicity 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 explicity 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 macro expressions, avoid using identifiers of lower visibility than the one macro is declared in. This may cause "Undeclared identifier" errors if macro 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 预处理器: 表达式语法

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 macros 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).

The 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 argument, if it is used in argument list.
  • Arithmetic division operator (slash) performs integer division, since ISPP does not support floating point math.
  • ISPP does not check for validity of expressions is 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).

数据类型

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 expression by using a slash and an asterisk. For example:

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

Also one line comments are supported. Those comments must begin with a semicolon. Whole text after the semicolon up to the end of a line is considered comment.

#emit Var1 + Var2 ; this is a comment

Please note that line spanning feature is triggered before any further processing, thus a comment may occupy more than one line:

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

Extended Macro Call Syntax

In ISPP it is possible to use named arguments when calling user defined macro. Given the declaration:

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

This macro can be called specifying argument names:

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

  • If a name is specified for one argument, then all (required) arguments in the list must also be named.
  • The order of named arguments 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 MyMacro((MyVar = 5), 10)

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

    Although functions do not have named arguments, 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 paretheses:

    #emit MyMacro((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 argument delimitter.


Inno Setup 预处理器: 扩展的命令行编译器

Inno Setup 预处理器取代标准 Inno Setup 命令行编译器 (ISCC.exe) 为扩展版本。该扩展版本提供额外参数控制 Inno Setup 预处理器。

用法: iscc [选项] <脚本名> 。或者从标准输入读取: iscc [选项] - .

选项有效的 define 或 pragma 指令是:

/d<名称>[=<值>] | 设置 #define public <名称> <值>
/$<字母>(+|-) | 设置 #pragma option -<字母>(+|-)
/p<字母>(+|-) | 设置 #pragma parseroption -<字母>(+|-)
/i<路径> | 设置 #pragma include -<路径>
/{#<字符> | 设置 #pragma inlinestart -<字符>
/}<字符> | 设置 #pragma inlineend -<字符>
/v<数字> | 设置 #pragma verboselevel -<数字>

其他有效的选择是: "/O" 指定输出路径 (覆盖脚本中的 OutputDir 设置)，"/F" 指定输出文件名 (覆盖脚本中的 OutputBaseFilename 设置)，和 "/Q" 安静编译 (只显示错误信息)。

示例: iscc /$c- /pu+ "/dLic=Trial Lic.txt" /iC:\INC;D:\INC "c:\isetup\samples\my script.iss"

ISCC 返回退出代码: 0. 如果编译成功; 1. 如果命令行参数无效或发生内部错误; 2. 如果编译失败。


Inno Setup 预处理器: AddBackslash

AddBackslash

#define AddBackslash(str S)

描述

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

Declared in ISPPBUILTINS.ISS 文件.


Inno Setup 预处理器: #append

语法

append-directive: append

描述

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

请查阅

insert.


Inno Setup 预处理器: ChangeFileExt

ChangeFileExt

#define ChangeFileExt(str FileName, str NewExt)

描述

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

Declared in ISPPBUILTINS.ISS 文件.


Inno Setup 预处理器: Copy

原型

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

描述

Function extracts a substring from a string (first argument). The 1-based index of the character from which the substring should start is specified by the second argument. The third argument 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 预处理器: CopyFile

原型

void CopyFile( str 1, str 2)

描述

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


Inno Setup 预处理器: Current translation

Current translation 是指ISPP的当前输出，the translated (preprocessed) part of the script up to the point (or line) which ISPP is currently processing.


Inno Setup 预处理器: DecodeVer

DecodeVer

#define DecodeVer(int Ver, int Digits = 3)

描述

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 预处理器: #define

语法

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

描述

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

The second syntax ("macro-definition") defines a macro named ident . When defining a macro there must be no whitespace between macro 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 macro definitions in this file. If no visibility declaration occurs in a file, public visibility is assumed by default.

示例

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

请查阅

dim, undef, 标识符的可见性 .


Inno Setup 预处理器: Defined

原型

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

描述

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

Using parentheses is optional.


Inno Setup 预处理器: Delete

Delete

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

描述

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 预处理器: DeleteFile

原型

void DeleteFile( str )

描述

标记为删除指定文件，在编译完成后 (不论成功或失败)。不返回任何值。


Inno Setup 预处理器: #dim, #redim

语法

dim-directive: dim [private | protected | public] <ident> [ <expr> ]
redim-directive: redim [private | protected | public] <ident> [ <expr> ]

描述

Use dim to declare an array variable and set its dimension. All 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.

示例

#dim MyArray[10]
#define MyArray[0] 15
#redim MyArray[20]
#define MyArray[10] 30
#redim MyArray[10]

请查阅

define, undef, DimOf , 标识符的可见性 .


Inno Setup 预处理器: DimOf

原型

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

描述

Special function. Returns the dimension of the specified identifier.

Using parentheses is optional.

清查阅

dim, redim.


Inno Setup 预处理器: DirExists

原型

int DirExists( str )

描述

返回非零值，如果该文件夹(文件夹名作为参数)存在。


Inno Setup 预处理器: #emit

语法

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

描述

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.

示例

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

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

请查阅

expr .


Inno Setup 预处理器: EncodeVer

EncodeVer

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

描述

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 预处理器: EntryCount

原型

int EntryCount( str )

描述

Function returns the total number of entries in specified section in current translation. 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 预处理器: #error

语法

error-directive: error <text>

描述

Directive 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.

示例

#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

请查阅

pragma, if.


Inno Setup 预处理器: Exec

原型

int Exec( str 1, str ? 2, str ? 3, int ? 4, int ? 5)

描述

执行指定的可执行文件。

第一个参数指定要执行的文件模块名。

第二个参数指定要以命令行方式执行。

Third argument may be used to specify the working directory of the process.

Fourth argument should 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.

Fifth argument can be any of the SW_* constants defined in ISPPBUILTINS.ISS 文件. For GUI processes, it specifies the default value the first time ShowWindow is called. By default, SW_SHOWNORMAL (i. e. 1) is assumed.

If fourth argument 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).


Inno Setup 预处理器: #expr

语法

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

描述

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

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

示例

#expr SaveToFile ("preprocessed.iss"), Exec ("notepad.exe", "preprocessed.iss")

请查阅

emit.


Inno Setup 预处理器: ExtractFileExt

ExtractFileExt

#define ExtractFileExt(str PathName)

描述

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

Declared in ISPPBUILTINS.ISS 文件.


Inno Setup 预处理器: ExtractFileName

ExtractFileName

#define ExtractFileName(str PathName)

描述

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 预处理器: ExtractFilePath

ExtractFilePath

#define ExtractFilePath(str PathName)

描述

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 预处理器: #file

语法

file-directive: file <expr>

描述

Replaces the directive with the name of a temporary file containing the translation of the specified file. Upon end of compilation, the temporary file is automatically deleted.

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 .

示例

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

请查阅

include.


Inno Setup 预处理器: FileClose

原型

void FileClose( int )

描述

The function closes open file and releases all resources allocated by a call to FileOpen . After calling FileClose , the file handle becomes invalid.

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


Inno Setup 预处理器: FileEof

原型

int FileEof( int )

描述

The function 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 预处理器: FileExists

原型

int FileExists( str )

描述

返回非零值，如果该文件(文件名作为参数)存在。


Inno Setup 预处理器: FileOpen

原型

int FileOpen( str )

描述

This function 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 预处理器: FileRead

原型

str FileRead( int )

描述

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

示例

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

请查阅

define, sub, pragma, for, if.


Inno Setup 预处理器: FileReset

原型

void FileReset( int )

描述

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


Inno Setup 预处理器: FileSize

原型

int FileSize( str )

描述

位。如果文件不存在，将返回 -1。Beware of ISPP supporting only signed 32 bit integers: for files larger than 2 GB (and smaller than 4 GB) the result is negative.


Inno Setup 预处理器: Find

原型

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

描述

Find function is intended to be used with insert directive. Function returns the index of the line in a translation 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.

请查阅

insert.

  • Find 标记


Inno Setup 预处理器: Find 标记

描述

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 arguments 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 previos 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 argument of the Find function. It is not mutually exclusive with any of the previously mentioned flags.


Inno Setup 预处理器: FindClose

原型

void FindClose( int )

描述

FindClose termiates FindFirst / FindNext sequence. The parameter must be 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 预处理器: FindCode

FindCode

#define FindCode()

描述

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

Declared in ISPPBUILTINS.ISS 文件.


Inno Setup 预处理器: FindFirst

原型

int FindFirst( str , int )

描述

FindFirst 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.

示例

#define FindHandle
#define FindResult
#define Mask "*.pas"

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

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

请查阅

define, sub, if.


Inno Setup 预处理器: FindGetFileName

原型

str FindGetFileName( int )

描述

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 预处理器: FindNext

原型

int FindNext( int )

描述

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


Inno Setup 预处理器: FindSection

FindSection

#define FindSection(str Section = "Files")

描述

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

Declared in ISPPBUILTINS.ISS 文件.


Inno Setup 预处理器: FindSectionEnd

FindSectionEnd

#define FindSectionEnd(str Section = "Files")

描述

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

Declared in ISPPBUILTINS.ISS 文件.


Inno Setup 预处理器: #for

语法

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

描述

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.

示例

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

更多示例

FindFirst , FileRead .

请查阅

sub, include.


Inno Setup 预处理器: GetDateTimeString

原型

str GetDateTimeString( str , str , str )

描述

以字符串形式返回当前日期和时间。

用指定的格式返回当前日期和时间为一个字符串。

支持下列格式:

d | 不带前导零 (1-31) 用数字显示天。
dd | 带一个前导零 (01-31) 用数字显示天。
ddd | 以缩写显示天 (Sun-Sat)。
dddd | 显示天的完整名 (Sunday-Saturday)。
ddddd | 用系统短日期格式显示日期。
dddddd | 用系统长日期格式显示日期。
m | 不带前导零 (1-12) 显示月。如果直接指定 m，然后指定 h 或 hh，用分钟代替月显示。
mm | 带一个前导零 (01-12) 显示月。如果直接指定 m，然后指定 h 或 hh，用分钟代替月显示。
mmm | 以缩写显示月 (Jan-Dec)。
mmmm | 显示月的完整名 (January-December)。
yy | 用两位数显示年 (00-99)。
yyyy | 用四位数显示年 (0000-9999)。
h | 不带前导零 (0-23) 用数字显示小时。
hh | 带一个前导零 (00-23) 用数字显小时。
n | 不带前导零 (0-59) 用数字显示分钟。
nn | 带一个前导零 (00-59) 用数字显示分钟。
s | 不带前导零 (0-59) 用数字显示秒。
ss | 带一个前导零 (00-59) 用数字显示秒。
t | 用系统短时间格式显示时间。
tt | 用系统长时间格式显示时间。
am/pm | 用 12 小时制显示前面所述 h 或 hh。中午前任何小时显示“am”，中午后任何小时显示“pm”。am/pm 指定可以使用小写、大写或混合大小写，并作为结果显示。
a/p | 用 12 小时制显示前面所述 h 或 hh。中午前任何小时显示“a”，中午后任何小时显示“p”。a/p 指定可以使用小写、大写或混合大小写，并作为结果显示。
/ | 用 DateSeparator 参数显示日期分隔符。如果 DateSeparator 设置为 #0，将用系统日期分隔符替换。
: | 用 TimeSeparator 参数显示时间分隔符。如果 TimeSeparator 设置为 #0，将用系统时间分隔符替换。
'xx'/"xx" | 附在单或双引号中的字符显示，不显示格式。

格式指定可以用大写，也可以用小写--两者生成相同的结果。

示例

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


Inno Setup 预处理器: GetEnv

原型

str GetEnv( str )

描述

返回指定名称的环境变量值。如果变量没找到，返回空字符串。


Inno Setup 预处理器: GetFileDateTimeString

原型

str GetFileDateTimeString( str , str , str , str )

描述

使用指定格式返回指定文件的日期与时间。

第一个参数是文件名。第二，第三和第四参数，是指格式串，DateSeparator 和 TimeSeparator 参数说明请查阅 GetDateTimeString 主题。

示例

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


Inno Setup 预处理器: GetFileVersion

原型

str GetFileVersion( str )

描述

GetFileVersion function takes a string argument which must be set to the name of the file whose version information is to be queried. The function returns string composed of four decimal numbers delimitted with periods. If file does not contain valid version info, the function returns an empty string.

ISPP also has GetStringFileInfo function, which also can be used to retrieve file version (using "FileVersion" or "ProductVersion" as second parameter). The difference is that GetFileVersion takes it from fixed block of version info, unlike GetStringFileInfo, which extracts string from language specific block.


Inno Setup 预处理器: GetMD5OfFile

原型

str GetMD5OfFile( str )

描述

获取指定文件的 MD5 校验值为一个字符串。


Inno Setup 预处理器: GetMD5OfString

原型

str GetMD5OfString( str )

描述

以字符串形式获取指定Ansi字符串的 MD5 校验值。

示例

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


Inno Setup 预处理器: GetMD5OfUnicodeString

原型

str GetMD5OfString( str )

描述

以字符串形式获取指定Unicode字符串的 MD5 校验值。

Causes an internal error if called during non Unicode compilation.

示例

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


Inno Setup 预处理器: GetSHA1OfFile

Prototype

str GetSHA1OfFile( str )

描述

获取指定文件的 SHA1 校验值为一个字符串。


Inno Setup 预处理器: GetSHA1OfString

Prototype

str GetSHA1OfString( str )

描述

以字符串形式获取指定Ansi字符串的 SHA1 校验值。


Inno Setup 预处理器: GetSHA1OfUnicodeString

Prototype

str GetSHA1OfString( str )

描述

以字符串形式获取指定Unicode字符串的 SHA1 校验值。

Causes an internal error if called during non Unicode compilation.


Inno Setup 预处理器: GetStringFileInfo

原型

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

描述

GetStringFileInfo function retrieves string from specified file's (first argument) version information resource.

Second argument is the name of the version info string-value. This should be one of the predefined strings. Those strings and shortcut macros are declared in ISPPBUILTINS.ISS 文件.

Third optional argument should specify 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 预处理器: #if, #elif, #else, #endif

语法

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

描述

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, else 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).

示例

#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 预处理器: #ifdef, #ifndef, #ifexist, #ifnexist

语法

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

描述

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.

示例

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

请查阅

FileExists


Inno Setup 预处理器: #include

语法

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

描述

Includes the translation of the specified file.

If the filename is enclosed in angle brackets, 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 quotes, 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.

示例

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

请查阅

file, sub.


Inno Setup 预处理器: #insert

语法

insert-directive: insert <expr>

描述

Changes the insertion point. By default, each processed line is added to the end of the translation. Using insert the point at which the next processed line will be added to the translation 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 line has been added to the translation, 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 translation 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.

示例

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

请查阅

append .


Inno Setup 预处理器: Insert

Insert

#define Insert(str *S, int Index, str Substr)

描述

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

Declared in ISPPBUILTINS.ISS 文件.


Inno Setup 预处理器: Int

原型

int Int( any 1, int ? 2)

描述

Function converts an expression (first argument) 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 预处理器: Len

原型

int Len( str )

描述

返回指定字符串的长度。


Inno Setup 预处理器: Macros' Local array

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

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


Inno Setup 预处理器: LowerCase

原型

str LowerCase( str )

描述

LowerCase 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 预处理器: Max

Max

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

描述

Declared in ISPPBUILTINS.ISS 文件.


Inno Setup 预处理器: Min

Min

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

描述

Declared in ISPPBUILTINS.ISS 文件.


Inno Setup 预处理器: ParseVersion

ParseVersion

#define ParseVersion(str FileName, *Major, *Minor, *Rev, *Build)

描述

Calls the GetFileVersion function and parses the string returned by that function (in form "0.0.0.0"). All four version elements are stored in by-reference parameters Major, Minor, Rev, and Build. Returns the string returned by GetFileVersion.

Declared in ISPPBUILTINS.ISS 文件.


Inno Setup 预处理器: Pos

原型

int Pos( str 1, str 2)

描述

Pos 搜索 str 1，并返回一个在 str 2 中 str1 的第一个字符索引整数值。。。 Pos 区分大小写。如果 str 1 未找到， Pos 返回零。


Inno Setup 预处理器: Power

Power

#define Power(int X, int P = 2)

描述

Declared in ISPPBUILTINS.ISS 文件.


Inno Setup 预处理器: #pragma

语法

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>

描述

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

First syntax of pragma directive controls the options, which ISPP uses to read the source. There are two groups of options. Each group consists of 26 flags (not all of them are meaningfull and used by ISPP, though). Each flag has an assigned latin letter. You specify options by typing group name ( option or parseroption ),then the letter following the dash. After a letter a plus or minus sign shall be specified. Plus sign to turn the option on, minus to turn it off. Unrestricted number of options can be specified at once (see syntax).The list of options is provided at the end of this topic.

First group of options ( option ) controls the options of the whole ISPP engine, while second group ( parseroption ) controls options specific to parser. The list of options is provided at the end of this topic.

Second syntax 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. Only first seven symbols from the string are taken. It is allowed to specify the same token for both starting and ending terminators. By default, {# (opening brace and a number sign) and } (closing brace) are assumed.

Third syntax of pragma directive 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.

Fourth syntax sets the level of verbosity. When the verbose mode is on (see below), this syntax controls the level of importance of messages. Least important messages will show up only when highest verbose level (9) is set.

Fifth syntax sets the include path. Expression may specify multiple paths delimitted with semicolons. The list of these directories is used when ISPP tries to find a file, mentioned in include directive.

The last syntax 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 选项

c | Indicates that the translation should be sent to the compiler after preprocessing is done. Default state: on.
e | Specifies whether empty lines from the source should be emitted to the translation, as well as lines with ISPP directives should be replaced with empty lines. Default state: off.
v | Turns on/off the verbose mode. Default state: off.

解析选项

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.

示例

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


Inno Setup 预处理器: ReadIni

原型

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

描述

从INI文件中读取值。Argument 1 must be the name of the INI file, argument 2 – the name of a section in the INI file, the third argument is the key in the section to read. Last optional argument 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 预处理器: ReadReg

原型

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

描述

Reads the value of the specified key in system registry. First parameter is the root key, such as HKEY_LOCAL_MACHINE. 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 value of any type depending on the type of actual value in registry.


Inno Setup 预处理器: RemoveBackslash

RemoveBackslash

#define RemoveBackslash(str S)

描述

Removes the trailing backslash from the string unless the string points to a root directory.

Declared in ISPPBUILTINS.ISS 文件.


Inno Setup 预处理器: RPos

原型

int RPos( str 1, str 2)

描述

RPos searches for a substring (first argument) in another string (second argument) 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 预处理器: SaveToFile

原型

void SaveToFile( str )

描述

This function saves current translation to the specified file.


Inno Setup 预处理器: SetSetupSetting

原型

void SetSetupSetting( str 1, str 2)

描述

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

If there is no [Setup] section in current translation (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 预处理器: SetupSetting

原型

str SetupSetting( str )

描述

SetupSetting function parses [Setup] section in current translation 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 预处理器: Str

原型

str Str( any )

描述

函数转换表达式为字符。如果表达式为数字，the result is its string representation。如果表达式为空，将返回一个空字符串。否则返回的是表达式的值。


Inno Setup 预处理器: StringChange

原型

str StringChange( str , str , str )

描述

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

示例

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


Inno Setup 预处理器: #sub, #endsub

语法

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

描述

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 make think of a user defined procedure as begin 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 translation 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.

示例

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

更多示例

FindFirst , FileRead .

请查阅

用户自定义宏 , if, emit.


Inno Setup 预处理器: Translation

Translation 是指已预处理脚本。


Inno Setup 预处理器: Trim

原型

str Trim( str )

描述

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


Inno Setup 预处理器: TypeOf

原型

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

描述

Special function. Returns one of predefined TypeOf constants which are declared in ISPPBUILTINS.ISS 文件 for the specified identifier.

Using parentheses is optional.


Inno Setup 预处理器: #undef

语法

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

描述

Undefines (removes) a variable or macro. 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.

示例

#undef MyVar
#undef MyMacro
#undef public MyVar

请查阅

define, dim, 标识符的可见性 .


Inno Setup 预处理器: WriteIni

原型

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

描述

写入指定值到一个INI文件。Argument 1 is the name of the INI file, argument 2 – the name of a section in the INI file, argument 3 – the name of a key in the section. Last argument should be set to the value you wish to be written to the INI file, it can be of any type.


Inno Setup 预处理器: YesNo

YesNo

#define YesNo(str S)

描述

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

Declared in ISPPBUILTINS.ISS 文件.