Reputation: 840
I want to modify the parameters of a FileName
in the [Run]
section according to the state of some radio and check buttons. In my code section I have added:
function GetParameterString:String;
var
I: Integer;
s1, s2: String;
begin
for I := 0 to WizardForm.RunList.Items.Count - 1 do
if (wizardform.runlist.items.checked[i] = true) then begin
if (wizardform.runlist.items.itemcaption[i] = 'View Whats''s New in ' + {#MyAppVersion}) then
s1 := GetShellFolderByCSIDL(CSIDL_APPDATA, True) + '\Positron Studio\What''s New.pdf';
if (wizardform.runlist.items.itemcaption[i] = 'Positron Studio Dark' then
s2 := '-d'
else if (wizardform.runlist.Items.itemcaption[i] = 'Positron Studio Light' then
s2 := '-l'
end;
end;
Result := s1 + s2
end;
and I am calling it from the [Run]
section like this:
FileName:"{app}\{#MyAppExename}"; parameters: Code: GetParameterString; \
Flags: postinstall nowait
It fails on the wizardform.runlist.items.checked[i] = true
with:
Unknown Identifier Checked
How do I get the Checked
value of a checkbox or radiobutton?
Upvotes: 1
Views: 91
Reputation: 202642
Your immediate problem is that there's indeed no wizardform.runlist.items.checked
(nor wizardform.runlist.items.itemcaption
).
You want WizardForm.RunList.Checked
(and WizardForm.RunList.ItemCaption
).
See the TNewCheckListBox
documentation.
Your next problem will be the invalid syntax of the reference to your scripted constant in the Parameters
parameter (as Andrew has already shown in his answer). It should be:
Parameters: {code:GetParameterString};
Your next problem will be "Invalid prototype":
"Identifier Expected" or "Invalid Prototype" when implementing a scripted constant in Inno Setup
It should be:
function GetParameterString(Param: string): string;
Depending on how you application handles the argument, you also might need to quote the path to the .pdf, as there are spaces in it.
It also bit strange, how you add the -d
and -l
to the path. Did you really intend to pass something like this to the application?
C:\Users\user\AppData\Roaming\Positron Studio\What's New.pdf-d
It also bit unclear to me, how are you combining multiple "run list" entries states into arguments of one particular entry. But I assume you know what you are doing.
Upvotes: 1
Reputation: 19197
Lookup Pascal Scripting: Scripted Constants where it states:
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 1String
parameter namedParam
, and must return aString
or aBoolean
value depending on where the constant is used.
So try:
FileName: "{app}\{#MyAppExename}"; Parameters: {code:GetParameterString}; Flags: postinstall nowait
The above has not been tested. It may not fix the underlaying issue with what you are actually doing in the GetParameterString
method.
Upvotes: 1