Mark Morgan Lloyd <markmll.fpc-ot...@telemetry.co.uk> wrote the following on 09/02/12 14:10:56: > tazmande...@centrum.cz wrote: > > 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.
I've seen several languages which permitted what the OP asked, but they were all interpreted. _______________________________________________ fpc-other maillist - fpc-other@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-other