[fpc-pascal] Boolean case statement

Steve Williams stevewilliams at kromestudios.com
Tue Dec 5 22:47:20 CET 2006


Terry Kemp wrote:
> 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 :(
>   

Of course it won't work.  It is invalid syntax.  You need to test each 
member using an if statement.

if EngMode.ManualOp then ManualOpRun;
if EngMode.LeakTest then LeakTestRun;
if EngMode.DrainFlush then DrainFlushRun;


-- 
Sly




This message and its attachments may contain legally privileged or confidential information. This message is intended for the use of the individual or entity to which it is addressed. If you are not the addressee indicated in this message, or the employee or agent responsible for delivering the message to the intended recipient, you may not copy or deliver this message or its attachments to anyone. Rather, you should permanently delete this message and its attachments and kindly notify the sender by reply e-mail. Any content of this message and its attachments, which does not relate to the official business of the sending company must be taken not to have been sent or endorsed by the sending company or any of its related entities. No warranty is made that the e-mail or attachment(s) are free from computer virus or other defect.




More information about the fpc-pascal mailing list