program fnbits,1.0(100) ! test Fn'Bitxxx$() ! Author: Jack McGregor ! Date: 21-Apr-09 !--------------------------------------------------------------------- !Notes: ! Tests the functions: ! Fn'BitSet$(bitfield,bitno) - Set a bit ! Fn'BitClr$(bitfield,bitno) - Clr a bit ! Fn'BitToggle$(bitfield,bitno) - Toggle a bit ! Fn'BitIsSet(bitfield,bitno) - Test a bit !-------------------------------------------------------------------- !{Edit History} ! 21-Apr-2009 --- 100 --- Jack McGregor ! Created !--------------------------------------------------------------------- !{end history} ++pragma ERROR_IF_NOT_MAPPED "TRUE" ++include ashinc:ashell.def ++include sosfunc:fnbits.bsi map1 bits,x,MAX_BIT_FIELD map1 bitnum,b,2 map1 fun,b,2 map1 a$,s,1 map1 funname$(4),s,10 !{End map zone} data "set", "clear", "toggle", "test" read funname$(1),funname$(2),funname$(3),funname$(4) ? tab(-1,0);"Test Fn'Bitxxx functions (bit set/clr/toggle/test)" mainloop: fun = 0 input "function: 1=set, 2=clr, 3=toggle, 4=test (0=end): ",fun if fun < 1 or fun > 4 End ? "bit # to ";funname$(fun);" (0=all): "; input "",bitnum on fun call set, clear, toggle, test debug.print "bitfield (1st 3 bytes): "+asc(bits[1;1])+","+asc(bits[2;1])+","+asc(bits[3;1]) goto mainloop set: bits = Fn'BitSet$(bits,bitnum) return clear: bits = Fn'BitClr$(bits,bitnum) return toggle: bits = Fn'BitToggle$(bits,bitnum) return test: if Fn'BitIsSet(bits,bitnum) then ? "Bit is set [TRUE]" else ? "Bit is not set [FALSE]" endif return !{Exit Program} End !{ErrorTrap} TRAP: END