[fpc-pascal] No type info available for this type (Enumerated type with constant assignment)

Martok listbox at martoks-place.de
Mon Jul 23 22:34:37 CEST 2018


Am 23.07.2018 um 19:47 schrieb Sven Barth via fpc-pascal:
> Though you'll get an access violation if you use a value that's not part of the
> enum (in the example this will happen when the loop reaches the value 3).
Not an AV - an IOError, so it's easy and safe to catch.

I use stuff like this, with aValue being of a generic type:
  {$IOChecks OFF}
  WriteStr(Result, aValue);
  if IOResult = 107 then
    Result:= '';

  ReadStr(aStr, a);
  Result:= IOResult <> 106;
  if Result then
    aValue:= a;

Turns out this is currently also the *only* typesafe way to check if an
arbitrary ordinal is a valid member of an enum type. But that's a different
story ;-)

-- 
Regards,
Martok




More information about the fpc-pascal mailing list