Hi Peter,
I put this header code at the top of your first sample. No crashes when invoking ScanBees(). Crashes are most often caused by array boundary errors, Could this be a possibility?
indexbase 0
sys map2[100]
sys xbm,beeras,icx,idx
ibx=10
sys xbee[100],ybee[100],ibee[100],rbee[100]
Charles
PS: AND has a higher precedence level than OR