Hello,
Is there something special that needs to be done to pass
strings by value?
The code below seems to mangle any strings I pass pretty well, when I
would assume it would only mangle the local copy in the function:
program testfunc(output);
var
aline : string (20) VALUE 'foo|bar|baz';
function countfields(line : string; axis : char) : integer;
var
count : integer VALUE 0;
begin
if length(line) > 0 then count := 1;
while index(line, axis) > 0 do
begin
count := count + 1;
line := substr(line, index(line, axis) + 1);
end;
countfields := count;
end;
begin
writeln(aline);
writeln(countfields(aline, '|'), ' field(s)');
writeln(aline);
end.
Under either 971001, or the 980106 alpha I get the following output:
foo|bar|baz
3 field(s)
baz
which is what I would expect if countfields() accepted 'line' as a
VARiable parameter.
-Kevin
--
Kevin A. Foss --- kfoss(a)mint.net
--