program t89_varstr; { t89 -- VAR string parameters. CALC.INC's GetFileName is procedure GetFileName(var Line : AnyString; FileType : String3); and the callee must operate on the CALLER's string, not on a copy. This exercises the address slot for the whole variable, a constant-index element (x[1]), a variable-index element (x[i]), Length, assignment of a literal and of a concatenation, and a function whose formal is VAR string. Hand-derived output: hello setit copies the literal through the caller's address 5 Length reads the length byte through that address Hello! upd writes x[1] and x[0], then appends through the address H the same element read back } var S : string[10]; I : integer; procedure setit (var X : string[10]); begin X := 'hello' end; procedure upd (var X : string[10]); var I : integer; begin X[1] := 'H'; X[0] := chr (5); for I := 1 to Length (X) do X[I] := X[I]; X := X + '!' end; function size (var X : string[10]) : integer; begin size := Length (X) end; begin setit (S); writeln (S); writeln (size (S)); upd (S); writeln (S); I := 1; writeln (S[I]) end.