Inno Setup - Pascal code visibility - “Unknown ide

2019-02-20 01:54发布

I have a file in my installer with an AfterInstall action like so:

AfterInstall: UpdateImageLoaderConfigValues()

And I would like the procedure to call the same Pascal Script function twice as I can't have two AfterInstall actions as far as I am aware, so I have set this up like so:

procedure UpdateImageLoaderConfigValues();
begin
  SaveValueToXML(ExpandConstant('{app}\ImageLoader.exe.config'),{#ImageLoaderLastConfigurationPath}, ExpandConstant('{app}/Configurations'))
  SaveValueToXML(ExpandConstant('{app}\ImageLoader.exe.config'),{#ImageLoaderLastImagePath}, ExpandConstant('{app}/Images'))
end;

And my function SaveValueToXML has a signature:

function SaveValueToXML(const AFileName, APath, AValue: string);

The problem is that compilation fails because of

Unknown identifier 'SaveValueToXML'

error at the points in UpdateImageLoaderConfigValues where I am trying to use this function.

How can I make SaveValueToXML visible to UpdateImageLoaderConfigValues?

1条回答
ゆ 、 Hurt°
2楼-- · 2019-02-20 02:05

You have to define the SaveValueToXML before the UpdateImageLoaderConfigValues:

[Files]
Source: ...; AfterInstall: UpdateImageLoaderConfigValues()

[Code]

function SaveValueToXML(const AFileName, APath, AValue: string);
begin
  // ...
end;

procedure UpdateImageLoaderConfigValues();
begin
  SaveValueToXML(ExpandConstant('{app}\ImageLoader.exe.config'),{#ImageLoaderLastConfigurationPath}, ExpandConstant('{app}/Configurations'))
  SaveValueToXML(ExpandConstant('{app}\ImageLoader.exe.config'),{#ImageLoaderLastImagePath}, ExpandConstant('{app}/Images'))
end;
查看更多
登录 后发表回答