Inno Setup Preprocessor: #sub, #endsub

Inno Setup Preprocessor

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

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 Macros, if, emit.