Bob Blick escreveu: > On Wed, 25 Nov 2009 14:26:01 +0800, "Justin Richards" > said: > = >> Thanks Bob, >> >> struggling to understand here but I guess would use it like >> >> if (bitof(days.day,tm_wday)) >> { >> do something >> } >> >> and if tm_wday =3D 1 (monday) >> >> it expand to >> >> if(((bitv *)&(days.day))->b1) >> >> and now I am lost. What is bitv and how can I break it down further. >> >> Cheers Justin >> 2009/11/25 Bob Blick >> >> = >>> You might be able to use this to help you access bits: >>> >>> #define _paste(a,b) a##b >>> #define bitof(var,num) (((bitv *)&(var))->_paste(b,num)) >>> = > > I didn't write it, but it's just a preprocessor construct that allows > you to treat bits within a variable similarly to an array and you don't > need to use separate getters and setters. So you can do something like > this: > > if ((today=3D=3DMONDAY) && (bitof(days,MONDAY))) > MondayTask(); > > and this would also work: > > if ((menuitem=3D=3DMONDAY) && (ButtonPress())) > bitof(days,MONDAY) =3D 1; > > I was really sleepy when I saw your first post so I don't remember what > it was exactly you were doing, but having this as an option for you may > work out somewhere. > > Cheerful regards, > > Bob > = It appears that Justin needs the bit-index to be variable. If so, the macro won't work because the macro is expanded at compile time and need the bit number to be a constant. Best regards, Isaac __________________________________________________ Fa=E7a liga=E7=F5es para outros computadores com o novo Yahoo! Messenger = http://br.beta.messenger.yahoo.com/ = -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist