ArianeSoft Forums

ArianeSoft Forums (http://forums.arianesoft.ca//index.php)
-   Code Sharing (http://forums.arianesoft.ca//forumdisplay.php?f=20)
-   -   your own bitfield / status flags like spriteoptions (http://forums.arianesoft.ca//showthread.php?t=1967)

Nicknack 03-29-2010 03:53 PM

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



All times are GMT. The time now is 08:58 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) ArianeSoft Inc.