Inno Setup - Pascal code visibility - “Unknown identifier” error

瘦欲@ 提交于 2019-12-01 10:24:52

问题


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:


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;


来源:https://stackoverflow.com/questions/36567129/inno-setup-pascal-code-visibility-unknown-identifier-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!