Thank you. I saw all the examples you gave, but I still cannot master
how to use a variant record without a specified tag.

If you use a specific tag as in

type TFigure = record
               case ShapeName : TShapeList of
                  Rectangle: (Height, Width: Real);
                  Triangle: (Side1, Side2, Angle: Real);
                  Circle: (Radius: Real);
                  Ellipse, Other: ();
                  end;

then you will get an additional part in your record named "ShapeName" which can (but not necessarily must) be used to store the meaning of the record variants. If you don't use such a variable name as in

type TFigure = record
               case TShapeList of
                  Rectangle: (Height, Width: Real);
                  Triangle: (Side1, Side2, Angle: Real);
                  Circle: (Radius: Real);
                  Ellipse, Other: ();
                  end;

then you have to detect the meaning of the variants in some other way. In both cases you can directly access the variants as in TFigure.Triangle or TFigure.Rechtangle. But if you stored with one variant and read with another you will get a lot of mess. ;-)

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to