[fpc-pascal] Boolean case statement

Daniël Mantione daniel.mantione at freepascal.org
Tue Dec 5 22:44:41 CET 2006



Op Wed, 6 Dec 2006, schreef Terry Kemp:

> Hi All
> 
> how do you do a case statement on a record of booleans e.g...
> 
> Type
>  EngModeRec = Record
>   ManualOp: Boolean;
>   LeakTest: Boolean;
>   DrainFlush: Boolean;
>  end;
> 
> var
>  EngMode: EngModeRec;
> 
> I want to have...
> 
>  Case True of 
>   EngMode.ManualOp: ManualOpRun;
>   EngMode.LeakTest: LeakTestRun;
>   EngMode.DrainFlush: DrainFlushRun;
>  end; 
> 
> but of course this wont work :(

with engmode do
  begin
    if manualop then
      manualoprun;
    if leaktest then
      leaktestrun;
    if drainflushop then
      drainflushrun;
  end;

Daniël Mantione


More information about the fpc-pascal mailing list