3
votes

I'm trying to create an installer using Inno Setup, which I have never used before, and everything is working fine, except that I'd like a VERSION.txt file to be created on installation. Here's what I've got so far, at the very end of my script:

[Code]
procedure writeVersion();
begin
  SaveStringToFile(ExpandConstant('{app}\VERSION.txt'), '{#MyAppVersion}', False);
end;

procedure nowWrite();
begin
  writeVersion();
end;            

But there is no VERSION.txt file being created at all after I compile and run the installer. I've never used Pascal before, and this is as far as I could get before I gave up. Why is the file not being created?

EDIT:
I tried adding

begin
  nowWrite();          
end.

to the end as suggested by @TLama, but it is still not writing a new file.

Thanks in advance for the help!

1
Are you calling your nowWrite procedure from somewhere ? P.S. ExpandConstant is not needed for the second parameter which only expands the preprocessor's variable.TLama
As a debugging hint, check the expanded strings to see what they are. Probably writeln can be used to examine an expression though it might be hard to figure out where the output can be seen.wallyk
It's not Pascal. You need to call it at some occassion.TLama

1 Answers

1
votes

You have to call noWrite in an standard installer event. Currently your code is never called.

Supported events are listed on this page

for example:

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssPostInstall then
    nowWrite();  
end;

will call your custom code when the setup's finished. Just study the documentation to choose the event which matches to your needs.