Delphi procedures with string parameters

Viewed 1941

I faced a problem while working with procedures and strings in Delphi. The fact is that I expected to see the output string "1S2S3S4S5S6S" but the actual output is "1234S5S6". During the debug process it says that S1, S2, S3 and S6 string variables are not initialized (S1, S2, S3, S6 are '' strings, S4 and S5 have value 'S'). Can someone explain to me this? Here's the code:

program StringTest;

{$APPTYPE CONSOLE}

procedure MyProcedure(S1: String; const S2: String; var S3: String;
                      S4: String; const S5: String; var S6: String;
                      out S7: String);
begin
  S7 := '1' + S1 + '2' + S2 + '3' + S3 + '4' + S4 + '5' + S5 + '6' + S6;
end;

procedure Work;
var
  S: String;
begin
  S := 'S';
  MyProcedure(S, S, S, S, S, S, S);
  writeln(S);
end;

begin
  Work;
  readln;
end.
1 Answers
Related