Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concatenating string and integer fails with "Type mismatch" error

I have the following Inno Setup script, and I'm getting this error on the SaveStringToFile line:

Type Mismatch

Can anybody spot my mistake?

Thank you!

var
  ErrorCode: Integer;
begin
  ShellExec(
    'open', 'taskkill.exe', '/f /im procterm.exe', '', SW_HIDE,
    ewWaitUntilTerminated, ErrorCode);

  SaveStringToFile(
    'c:\program data\myapp\innolog.txt',
    'Error code for procterm was: ' + ErrorCode, True);
end;
like image 718
tmighty Avatar asked Mar 11 '23 17:03

tmighty


1 Answers

The problem is that you are trying to "sum" a string with a number (an integer):

'Error code for procterm was: ' + ErrorCode

That's not possible in Pascal/Pascal Script.

You have to convert the number/integer to a string with the IntToStr function:

'Error code for procterm was: ' + IntToStr(ErrorCode)

Or use the Format function like:

Format('Error code for procterm was: %d', [ErrorCode])
like image 68
Martin Prikryl Avatar answered Mar 20 '23 05:03

Martin Prikryl