[fpc-pascal] New Warnings with fpc >= 3.2.0

Santiago A. svaa at ciberpiula.net
Fri Mar 13 13:11:40 CET 2020


El 11/03/2020 a las 11:15, fredvs via fpc-pascal escribió:
> ---> tabulatorkindty = (tak_left,tak_right,tak_centered,tak_decimal,tak_none);
>
> ?
>
> And then use:
>
> --->  if (kind <> tabulatorkindty(tak_none) ?
>
> Or do you have a other idea?

Yes, for my taste that is the way to go.

But you don't need to convert the type:

if (kind <> tak_none)

Nevertheless. I supposse you are reading from a format that stores 
tabulatorkindty value as an integer. In such cases I want to be in the 
safe side and control  everything of external input data:

function ToTabulartoryKind(intValue:Integer):tabulatorkindty;
begin
   if (intValue>=ord(Low(tabulatorkindty))) and (intValue<=ord(high(tabulatorkindty)))
           then Result:=tabulatorkindty(intValue)
           else Result:=tak_none;

//you could use set and IN operando but sometimes I've had problems with big integers
end;

I'd probable would add a value tk_invalid.

-- 
Saludos

Santiago A.



More information about the fpc-pascal mailing list