Excuse me for being a bit slow 2day (due to a 4:30am start coz of Canadian
GP), but how do I do this in code.

<C++ Code>
#define TRANS_LEN 64

struct trs_general_
{
  unsigned char opcode;
  unsigned char sub_opcode;
  unsigned char data[TRANS_LEN - 2 - sizeof(struct trans_tail_)];
  struct trans_tail_ tail;
}

struct trs_plu_sale_
{
  unsigned char opcode;
  unsigned char plu_code[7];
  ..... {rest of structure 64 bytes in size}
}

struct trs_discount
{
  unsigned char opcode;
  unsigned char plu_code[7];
....... {rest of structure 64 bytes in size}
}

How do I do below in Delphi ??

union trans_
{
  unsigned char data[TRANS_LEN];
  struct trs_general_    general;
  struct trs_plu_sale_   plu_sale;
  struct trs_discount_   discount;
}

then

union trans_ TrsBuf;

switch (TrsBuf.general.OpCode)
{
   case TRANS_PLU_SALE:
      TreatPLUSale(&TrsBuf.plu_sale);
      break;
   case TRANS_DISCOUNT:
      TreatDiscount(&TrsBuf.discount);
      break;
}

BTW Don't worry about converting structures as I know how to do that etc.

TIA



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Monday, 11 June 2001 15:27
To: Multiple recipients of list delphi
Subject: Re[2]: [DUG]: Union


If possible store the option used...
I am working with a huge app here where almost none of them say which option
is
used...

blah = record
  case AOption: integer of
        0 : firstByte, secondByte, ThirdByte, fourthByte : byte;
        1 : firstInt, secondInt : word;
        2 : firstLong : longint
  end;
end;



Regards
Paul McKenzie

=========================
Paul McKenzie
Jetbet II Developer
=========================
[EMAIL PROTECTED]
Ph: (04) 576-6822

T.A.B. National Office
106-110 Jackson Street
Petone
New Zealand



____________________Reply Separator____________________
Subject:  Re: [DUG]:  Union
Author:   [EMAIL PROTECTED]
Date:          11/06/2001 15:19



     > Sorry to interrupt the great Nic and Nev  debate but ... ;-)

     hehe, oddly enough, we got on rather well in real life.


     >
     > Does Delphi have an equivalent to the Union statement in C++.
     >
     > I have some C++ code I want to convert to Delphi....
     >

     um:

     blah = record
       case integer of
         0 : firstByte, secondByte, ThirdByte, fourthByte : byte;
        1 : firstInt, secondInt : word;
        2 : firstLong : longint
       end;
     end;

     or something like that.

 
---------------------------------------------------------------------------
         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"(See attached file: att1.eml)




CAUTION - This message may contain privileged and confidential information intended 
only for the 
use of the addressee(s) named above.  If you are not the intended recipient of this 
message you are 
hereby notified that any use, dissemination, distribution or reproduction of this 
message is prohibited.  
If you have received this message in error please notify Progressive Enterprises Ltd. 
immediately via 
email at [EMAIL PROTECTED]  Any views expressed in this message 
are those of the 
individual sender and may not necessarily reflect the views of Progressive Enterprises 
Ltd.

This footnote also confirms that Progressive Enterprises Ltd. has swept this email 
message for the 
presence of computer viruses.  This does not guarantee this message is virus free.

---------------------------------------------------------------------------
    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"

Reply via email to