I have a procedure that accepts 2 string parameters, one of them has a default value. Inside the procedure, I want to concatenate one and the other and some literals to form one larger string. Somehow, I'm getting an AV... any ideas?
code is something like this
{$WRITEABLECONST ON}
constructor MyClass.Create(s1: string; s2: string = GlobalConstant);
var s3: string;
begin
....
if (s2 = '') then s2 := GlobalConstant + ' (' + s1 + ')'; // AV here
....
end;
If I assign GlobalConstant + ' (' + s1 + ')
to s3
, then assign s3
to s2
the AV disappears. Why? What is wrong with writing to the string parameter directly?