Pascal Scripting: Scripted Constants

The Pascal script can contain several functions which are called when Setup wants to know the value of a scripted {code:...} constant. The called function must have 1 String parameter named Param, and must return a String or a Boolean value depending on where the constant is used.

The syntax of a {code:...} constant is: {code:FunctionName|Param}

Example:
DefaultDirName={code:MyConst}\My Program

Here is an example of a [Code] section containing the MyConst function used above.

[Code]
function MyConst(Param: String): String;
begin
  Result := ExpandConstant('{pf}');
end;

If the function specified by the {code:...} constant is not included in the [Code] section, it must be a support function. Here is an example.

[INI]
FileName: "{app}\MyIni.ini"; Section: "MySettings"; Key: "ShortApp"; String: "{code:GetShortName|{app}}"


See also
Constants