I am using Inno Download Plugin to download a bunch of files for my installation. These files are listed in "files.json
".
FileList := TStringList.Create;
FileList.LoadFromFile(ExpandConstant('{tmp}\files.json'));
for i := 0 to FileList.Count-1 do
begin
fileName := ExtractFileName(FileList[i]);
StringChangeEx(FileList[i], '\', '/',True);
//Add each file to download queque
idpAddFile("www.myapiaddress.com/files/" + FileList[i], ExpandConstant('{tmp}\install\') + fileName );
Log(FileList[i]);
end;
What gives me a headache is the line StringChangeEx(FileList[i], '\', '/',True)
. As soon as I put that in, the idp.iss stops compiling, giving me the error: Variable expected
on
procedure idpAddFile(url, filename: String); external 'idpAddFile@files:idp.dll cdecl';
Installer compiles normal, if I remove StringChangeEx
from my script entirely. It does not help to place it in a different location...
Any idea, what might cause this problem?
The StringChangeEx
function needs a string
variable in the first argument (it's declared as var
). You are giving it a string
value only.
Your code would work, were FileList
a string
array. But it's not, it's a class with an array-like string
default property. Using a property value is an equivalent of using a function/method return value. A property is just syntactic sugar for getter and setter methods.
You will have to copy the value to a string
variable and back.
S := FileList[i];
StringChangeEx(S, '\', '/',True);
FileList[i] := S;
Though you actually do not need to copy it back in your case.
Regarding the reason why the error refers to idp.iss
file: There seems to be a bug in Inno Setup that makes it report the error as if it had occurred on the very first line of the Pascal Script code (what in your case is the very first real code in the included idp.iss
). I've posted a bug report. It was fixed already.