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 that may be included later, once or several times. A user defined procedure works much like an external file, and calling one works much like including that file, except that procedures may also be called from within expressions. Avoid calling procedures that emit several lines to the preprocessor output from within compound expressions or directives.

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

A procedure isn't processed until it's called, so errors in its body are reported only 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