Show quoted text 19 lines
Hi all,
how can i simple get type of variable in freepascal?
For example:
procedure RawWrite(v:anyvariable)
begin
if GETTYPE(v)=string_type then begin;stringwork(v);end;
if GETTYPE(v)=byte_type then begin;dobyte(v);end;
if GETTYPE(v)=pchar_type then...
if GETTYPE(v)=pointer_type then...
etc...
etc...
end;
or use a CASE statement
Is there any way to detect variable type?
How is anyvariable defined? If it's a simple array of bytes or words then there is not, since you've lost the type when assigning to it. If it's a variant record with a tag then you've got the tag. Otherwise consider using variants as supported by the language and RTL.
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]