'Invalid assignment/conversion'.
I'm guessing FB does not support constant arrays?
Or am I using const keyword incorrectly?
The commented out lines produce errors.
Code: Select all
' test flags
' arrays can't be constant?
const F01 = 1, F02 = 2, F03 = 4, F04 = 8
const MIN_FLAG = 1, MAX_FLAG = 4
dim as integer FLAG_ARRAY ( MIN_FLAG to MAX_FLAG ) = { F01, F02, F03, F04 }
'const FLAG_ARRAY ( MIN_FLAG to MAX_FLAG ) = { F01, F02, F03, F04 }
'dim as const integer FLAG_ARRAY ( MIN_FLAG to MAX_FLAG ) = { F01, F02, F03, F04 }
sub set_flag _
( _
byref flag as integer, _
byref target as integer _
)
target = target or flag
end sub
function get_flag _
( _
byref flag as integer, _
byref target as integer _
) as integer
if ( target and flag ) then return -1
return 0
end function
dim as integer bit_field
set_flag( F02, bit_field )
dim as integer test_bit
for test_bit = MIN_FLAG to MAX_FLAG
if get_flag( FLAG_ARRAY( test_bit ), bit_field ) then
? "Flag " & test_bit & " set."
else
? "Flag " & test_bit & " not set."
end if
next
sleep