Search code examples
inno-setuppascalscript

'Type missmatch' error when using StringChange in Inno Setup


I'm having troubles when trying to use StringChange / StringChangeEx. This code gives me the error "Type missmatch" on the line where I use StringChange:

function CustomSelectDirPageNextButtonClick(Sender: TWizardPage): Boolean;
var
  DirString: String;
begin
  Result := True;
  DirString := SetupMessage(msgDirExists);
  DirString := StringChange(DirString, '%1', WizardDirValue);
  // DirString := StringChangeEx(DirString, '%1', WizardDirValue, True);

  if MsgBox(DirString, mbConfirmation, MB_YESNO) = IDNO then
    Result := false;
  end;
end;

My obvious purpose is to replace the string "%1" with the value contained in WizardDirValue variable.

I'm working on Inno Setup v6.2.2 Unicode.

How do I fix this?.


Solution

  • StringChange() returns an Integer (the number of times a replacement was made). You try to assign that Integer to a string.

    StringChange() modifies the string already, so you don't need to assign it.

    Also note that the documentation says that this function is deprecated.