home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.pascal.borland      Borland Pascal was actually pretty neat      2,978 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 1,421 of 2,978   
   Heinrich Wolf to All   
   Re: Is there any reason NOT to word-alig   
   23 Feb 05 08:39:55   
   
   From: invalid@invalid.invalid   
      
   I use byte alignment for processing communication streams. A communication   
   level procedure only deals with messages built of bytes, not knowing the   
   meaning. A processing level procedure knows the structure of data fields in   
   the message. I describe the messages by variant records and I set alignment   
   to byte-level. So I can create code according to a message specification on   
   byte level, which is common to different applications or even different   
   machines.   
      
   const   
     cMessageA = 1;   
     cMessageB = 2;   
      
   type   
     tMessageA = record   
       wParam : Word;   
       bParam : Byte;   
       cParam : Array[0..5] of char;   
     end;   
      
     tMessageB = record   
       cParam : Array[0..6] of Char;   
       wParam : Word;   
       bParam : byte;   
     end;   
      
     tMessageVariant = Record   
       case MessageType : Byte of   
         cMessageA : (MessageA : tMessageA);   
         cMessageB : (MessageB : tMessageB);   
     end;   
      
     tMessageBuffer = Array of Byte;   
      
     tMessage = Record   
       case Byte of   
         0 : (Raw : tMessageBuffer);   
         1 : (Structured : tMessageVariant);   
     end;   
      
   var   
     Message : tMessage;   
      
   procedure CommunicationGetMessage(var Message : tMessageBuffer; Size :   
   Integer);   
     var b : char;   
           i : Integer;   
     begin   
       repeat   
         CommunicationGetByte(b);   
       until b = StartOfText;   
       i := 0;   
       while (b <> EndOfText) and (i < Size) do   
         begin   
           CommunicationGetByte(b);   
           Message[i] := b;   
           inc(i);   
         end;   
     end;   
      
   procedure ProcessMessage(Message : tMessageVariant);   
     begin   
       case Message.MessageType of   
         cMessageA:   
           begin   
           end;   
         cMessageB:   
           begin   
           end;   
       else   
       end;   
      
   begin   
     CommunicationGetMessage(Message.Raw, sizeof(Message));   
     ProcessMessage(Message.Structured);   
   end.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca