YOU WANT OPTIONS!!!! YOU CAN'T HANDLE OPTIONS!!!

I have has this idea buzzing around in the back of my head for some time now.

one of the problems i have run against when creating a UDF is setting option flags. Typically i have just used the simple OPTIONAL $flag and set it to equal a 1 if true. but this can lead to UDF's like this.

THING(1,0,1,1,1,0,1)

really nasty in my book.

Then I had one of those rare moments when everything becomes clear! Kix has several functions that have multiple options with out having to do the 1,0,1,1,0 dance!!!

and *click* i was able to come up with this.


;option flags can be 2,4,8,16,32,64,128,256,512,1024,2048...
$option = 4 + 16 + 64 +256 + 2+8


;a data array of available flags
$i = 1
while $i < 50000
$i = $i*2
$flags = $flags + "$i,"
loop
$flags = split($flags,",")
redim preserve $flags[ubound($flags)-1]


;sort throught the flag options.
? "the following flag options were set."
for each $flag in $flags

if ($option & val($flag))
? $flag
endif
next

Now you can have HUNDREDS! of available options in your UDF, with out having to do 1,1,1,0,0,1....

Bryce

[ 04 December 2001: Message edited by: Bryce ]