PDA

View Full Version : your own bitfield / status flags like spriteoptions


Nicknack
03-29-2010, 03:53 PM
was not much work. taken the example on wikipedia and ported it to PPL. maybe useful for somebody:
#define LIKES_ICE_CREAM (1 << 0) // 0x01
#define PLAYS_GOLF (1 << 1) // 0x02
#define WATCHES_TV (1 << 2) // 0x04
#define READS_BOOKS (1 << 3) // 0x08

proc set_preference(flag$)
preference$ |= flag$;
end;

proc reset_preference(flag$)
preference$ = (preference$ ^ flag$);
end;

func get_preference(flag$)
return (preference$ & flag$ !=0);
end;

proc main
global(preference$);
set_preference(LIKES_ICE_CREAM|PLAYS_GOLF|WATCHES_ TV|READS_BOOKS);
reset_preference(PLAYS_GOLF) ;
Showmessage(get_preference(PLAYS_GOLF) );
Showmessage(get_preference(READS_BOOKS) );
end;