E2054 Type non conforme dans une instruction Write/Writeln (Delphi)

De RAD Studio
Aller à : navigation, rechercher

Remonter à Messages d'erreur et d'avertissement (Delphi)

Cette erreur se produit lorsque vous essayez de sortir un type dans une instruction Write ou Writeln qui est incorrecte.



program Produce;
type
  TColor = (red,green,blue);
var
  Color : TColor;
begin
  Writeln(Color);
end.

Il aurait été intéressant d'utiliser une instruction writeln pour sortir Color, n'est-ce pas ?



program Solve;
type
  TColor = (red,green,blue);
var
  Color : TColor;
const
  ColorString : array [TColor] of string = ('rouge', 'vert', 'bleu');
begin
  Writeln(ColorString[Color]);
end.

Malheureusement, ceci est incorrect, et nous devons le faire avec un tableau auxiliaire.