Whats wrong with :

const
    constEraseFilesMenu = 1;
    constFormatDiskMenu = 2;

and then assign the tag the numbers in the const

i.e

EraseMenu1.Tag = 1 or whatever then you could

if (Sender is TMenuItem) then
   theTag := (Sender as TMenuItem).Tag

case theTag of
   constEraseFilesMenu :
        //do some stuff
   constFormatDiskMenu:
        //do some stuff

etc


----- Original Message -----
From: Alistair George <[EMAIL PROTECTED]>
To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
Sent: Friday, November 22, 2002 10:42 AM
Subject: Re[2]: [DUG]: Case Statement


> Hello Chris,
>
> It passed the first compile error but the second compile error:
> 'Constant expression expected'
>
> The sender(s) are tmenuitems thus the following
>   case longword(Sender) of
>   EraseFiles1:                             //'Constant expression
expected'
>   WriteInteger('Options', 'ClrDisk', 0);
>   FormatDisk1:
>   WriteInteger('Options', 'ClrDisk', 1);
>   end;
>
> erasefiles1 is the sender of tmenuitem
> ????
>
> It is a different way of doing it, but I thought if I could use the sender
of
> all the various checks and menu clicks it would save a lot of coding and
make it
> a lot easier to read.
> The other way would be to allocate each item a tag, but then the code is
nowhere
> as easy to read.
> Thanks,
> Al+
>
> --------------------------------------------------------------------------
-
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to