Problems with GetEnumName TypeInfo (pascal / Delphi console)

Working with a console application using Delphi 7, and there was a problem. I get an error on line 26 after

str: = GetEnumName (TypeInfo (words [3] .group),

The error is being read "[Error] Project1.dpr (26): the standard function TYPEINFO expects an identifier like" if someone can help with this, this will be a big help!

Hooray!

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  TypInfo;

type
  wordset = Record
    word  : String;
    group : (flavour, colour, place, animal);
  end;
Var
  words : Array [1..50] of wordset;
  str : string;
  groups: string;
Begin
  words[1].word  := 'chocolate';
  words[1].group := flavour;
  words[2].word  := 'vanilla';
  words[2].group := flavour;
  words[3].word  := 'strawberry';
  words[3].group := flavour;

  str := GetEnumName(TypeInfo (words[3].group), integer(group));

  readln;
end.
+3
source share
1 answer

, . ( TGroup).

, . Wordset TWordset. , , Delphi.

program Project1;

{$APPTYPE CONSOLE}

uses SysUtils, TypInfo;

type
  TGroup = (Flavour, Color, Place, Animal);

type
  TWordset = record
    Name: string;
    Group: TGroup;
  end;

var
  Str: string;
  Words: array [1..50] of TWordset;

begin
  Words[1].Name  := 'Vanilla';
  Words[1].Group := Flavour;
  Words[2].Name  := 'Green';
  Words[2].Group := Color;
  Words[3].Name  := 'Home';
  Words[3].Group := Place;
  Words[4].Name  := 'Cat';
  Words[4].Group := Animal;

  Str := GetEnumName(TypeInfo(TGroup), Integer(Words[3].Group));

  Writeln(Str);
  Readln;
end.
+7

All Articles