DeeJay007
DeeJay007

Reputation: 509

Computing a value of command parameter in Inno Setup Icons section

My question is the the continuation of Inno Setup - "Variant is null, cannot invoke" error while reading node value in XML file. In this post, I am reading an XML file node and successfully able to take the value using the procedure ProcGetWebAppNameFromXML and I am trying to pass the value to the [Icons] section, but I am getting empty.

The code snippet is mentioned below.

[Run]

Filename: "{app}\test1.bat"; StatusMsg: "Running Services..."; \
    BeforeInstall: ProcGetWebAppNameFromXML;

[Icons]
Name: "{commondesktop}\App"; Filename: "{pf}\Internet Explorer\iexplore.exe";  \
    Parameters: """http://{code:GetWebAppNameFromXML|}/"""

The procedure ProcGetWebAppNameFromXML gets the webapp name (works completely fine) and I am assigning it to a global variable.

[Code]
var
    WebAppNameFromXML: String;

procedure ProcGetWebAppNameFromXML();
var
    ...
    ...
    WebAppNameFromXML := LoadValueFromXML(applicationxmlFile, '//ns:application-name', 'application-name');
    Log('WebApp name is logged correctly here..' + WebAppNameFromXML);
end;

I am using the below mentioned function to assign the value.

function GetWebAppNameFromXML(Default: String): String;
begin
    Result := WebAppNameFromXML;
end;

When I pass the function GetWebAppNameFromXML to the Icons section I am getting empty. Please note that I have [Icons] below the [Run] section and I have used ChangesAssociations=yes too.

Thanks in advance.

Upvotes: 1

Views: 247

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202534

The [Run] section is processed as the last one. So after [Icons] section. See https://jrsoftware.org/ishelp/index.php?topic=installorder

And it looks like you are actually abusing it anyway.

Call ProcGetWebAppNameFromXML in CurStepChanged(ssInstall).

Or if you need WebAppNameFromXML for your [Icons] section only, read the XML directly in GetWebAppNameFromXML – And you won't need any global variables.

Upvotes: 1

Related Questions