[fpc-pascal] Variable arguments, different types?
L505
fpc505 at z505.com
Thu Mar 9 02:27:53 CET 2006
Hi, This below seems to work.. I got the impression you couldn't do this.
program HelloWorld;
var
I : Integer;
procedure test (args : array of const);
begin
writeln('test');
For i:=0 to High(Args) do
begin
case Args[i].vtype of
vtstring:
Writeln ('String value: ',args[i].vSTRING^);
vtinteger:
Writeln ('Integer value: ',args[i].vINTEGER);
end;
end;
end;
begin
test([1, 'test']); // variable types work
readln;
end.
In other words you can reinvent your own writeln style procedures and pass
parameters of *different types* simutaneously. I was under the impression you
could only pass parameters of the same type through this [] square bracket
trickery.
More information about the fpc-pascal
mailing list