Actually, I did make GetBit and SetBit functions. I completely understand your point. The only reason for trying this is for the fun of it. I know I can easily do the same thing using two functions, or even my combined function with two abilities (the one I posed last).
I also thought about the unsigned long vs. unsigned int. I figured that for testing purposes, it wouldn't hurt to over-do the available range.
Here are the GetBit and SetBit functions:
Code: Select all
safecall bool GetBit(unsigned long bit){
Acquire(bit_mutex);
byte result = (bit_array[bit / 8] >> (bit % 8)) & 0x01;
Release(bit_mutex);
return result;
}
safecall void SetBit(unsigned long bit, bool value){
Acquire(bit_mutex);
if(value){
bit_array[bit / 8] |= 1 << (bit % 8);
}
else{
bit_array[bit / 8] &= ~(1 << (bit % 8));
}
Release(bit_mutex);
}
However, I would still like some way of passing a value to a function through the assign process (e.g. function() = 3 * 4), even if it doesn't apply to this situation.