1
votes

Under the [Run] section in the Inno Setup script I have the following...

[Run]
Filename: "{sys}\cscript.exe"; \
  Parameters: """{tmp}\myScript.vbs"" ""{code:GetStringValue}"" {#CONST_PORT}"; \
  Description: "Setting the port to {#CONST_PORT}."; \
  StatusMsg: "Setting the port to {#CONST_PORT}."; \ 
  Tasks: SetPorts; \
  Check: SetPort({#CONST_PORT}); \
  Flags: runhidden;

Then in the [Code] section I have the following...

[Code]
function GetStringValue: String;
var
  version: Integer;
begin
  version := 20;
  result := 'This is a test showing the int ' + IntToStr(version);
end;

The object is to have a function that will return a string in the [Run] section. Currently from everything I can tell if using {code:} in the [Run] section you are required to call a function that only returns a Boolean value. Is there a way around this? I need to be able to get a dynamic string to pass to my VBScript in the [Run] section.

1

1 Answers

1
votes

Currently from everything I can tell if using {code:} in the [Run] section you are required to call a function that only returns a Boolean value.

That's not true.

Quoting the documentation on Scripted constants:

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.

In general, when the scripted (code:) constant is used in the Check parameter, it must return a Boolean. Everywhere else (as far as I can tell), it must return a String.


So your script is correct, except that you are missing the parameter (it's mandatory, even if you actually do not need/use it):

[Code]
function GetStringValue(Param: string): string;
...