External Links

Creative Science Centre

 

Library Miscl

Circular Buffer

// #include "http://www.byvac.com/mBlib/flb/Library/2016/lib_circ.bas"

Generic circular buffer for storing character information. Maximum size of buffer is 255, uses a string to store information.

  • dim buffer$[32]     // string to store data in
  • circular.int(?buffer$) // initialise storage string
  • k = circular.put(?buffer$,44) // store 44 to buffer, if k=1 then buffer full
  • c = circular.get(?buffer$) // c=0 if no bytes in buffer

Bytes can be placed into the buffer and then retrieved using circular.get until it returns 0 which means the buffer is empty.