Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
804 views
in Technique[技术] by (71.8m points)

pascalscript - Inno Setup - Pascal code visibility - "Unknown identifier" error

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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;

For others, who arrive here with the same error message, but on a variable identifier, rather than on a function or procedure call, , see Inno Setup Pascal script problem... "Unknown Identifier".


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...