[lazarus] "Variant" variable ?

dvortex dvortex at netcourrier.com
Thu Apr 27 12:08:26 EDT 2000




On Thu, 27 Apr 2000, Michael Van Canneyt wrote:

> 
> 
> On Thu, 27 Apr 2000, Marc Weustink wrote:
> 
> > At 23:20 26-04-2000 +0200, Michael Van Canneyt wrote:
> > 
> > >It is in the Case statement.
> > >
> > >Case A : Integer of
> > >   1 : (X : String;);
> > >   2 : (Y : Longint);
> > >end;
> > >
> > >If A=1 then you can access X as a string
> > >If A=2 then you can access Y as a Longint.
> > 
> > Is there a check on this? I allways thought that 1 and 2 are just 
> > placeholders?
> 
> There is no check; you must do the check. The point is that there are 2 constructs
> 
> Case A : Integer of
>    1 : (X : String;);
>    2 : (Y : Longint);
> end;
> 
> Here you can set A and thus have an indication which of X or Y you should access.
> (i.e. A is a normal field of the record)
> 
> On the other hand
> 
> Case Integer of
>    1 : (X : String;);
>    2 : (Y : Longint);
> end;
> 
> doesn't allow to determine what you should access, because there is no 'A' field.
> 
That's exactly what is confusing to me .... so how does this one work ?
(i'm just curious here, because i will be using the second one, although
now i am going towards a TVariant class type object with that sort of
construct... :o)

ok, back at hacking ...

Jok







More information about the Lazarus mailing list