TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Simon Avery
from: Kurt Kuzba
date: 1998-08-15 11:52:12
subject: More silly questions

SA> struct MESSAGErecord
SA> {
SA> // other stuff
SA> unsigned char  Attribute;
SA>               /* Bit 0 : Enable EchoInfo
SA>                1 : Combined access
SA>                2 : File attaches
SA>                3 : Allow aliases
SA>                4 : Use SoftCRs as characters
SA>                5 : Force handle
SA>                6 : Allow deletes
SA>                7 : Is a JAM area */
SA> // more stuff
SA> };
SA> Simple question. How do I modify the values?
   You just have to know the values for the bits.
int SetAttribute(void *byte, int bit, int op)
{
   static int mask[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
   unsigned char *A = byte;
   /*   This array will be used to index the bit values   */
   switch(op)
   {
      case '1': *A |= mask[bit]; break;
      /*   Turns on the appropriate bit using inclusive OR   */
      case '0': *A &= ~mask[bit]; break;
      /*   Turns off the appropriate bit using AND   */
      case 't': *A ^= mask[bit]; break;
      /*   Toggles the appropriate bit using exclusive OR   */
      default: break;
   }
   return !!(*A & mask[bit]);
   /*   returns the bit status normalized as 0 or 1   */
}
   This function illustrates how to use bitwise manipulation.
   You can also use it to simply read the bits, since it
   returns an appropriate value.
   Read a value:
bit_on = SetAttribute(&Attr, 4, 'r');
   Set a value to 1:
SetAttribute(&Attr, 4, '1');
   Set a value to 0:
SetAttribute(&Attr, 4, '0');
   Toggle a value:
SetAttribute(&Attr, 4, 't');
   Of course, this may not be the best method.
   It's just one way to go about it.

> ] Redundancy: Playing "Battle of Evermore" during housework...

---
* Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750)
SEEN-BY: 396/1 622/419 632/371 633/260 267 270 371 634/397 635/506 728 810
SEEN-BY: 639/252 670/213 218
@PATH: 154/750 222 396/1 633/260 635/506 728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.