View Single Post
  #1  
Old 03-29-2010, 04:53 PM
Nicknack Nicknack is offline
Senior Member
 
Join Date: Nov 2006
Location: Germany
Posts: 527
Default your own bitfield / status flags like spriteoptions

was not much work. taken the example on wikipedia and ported it to PPL. maybe useful for somebody:
PHP Code:
#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
Reply With Quote