10 REM > BLib.BBCFile 1.01 12Feb1992
   20 REM Read and write BASIC data using fast file IO
   30 :
   40 REM Note! These routines are actually *slower* than PRINT#
   50 REM and INPUT# on all filing systems other than NFS 3.xx
   60 :
   70 :
   80 REM PROCBBC_WrStr(out%,str$) - write string to file
   90 REM On entry: out% - handle to output file
  100 REM           str$ - string to write
  110 REM ------------------------------------------------
  120 DEFPROCBBC_WrStr(O%,A$):LOCAL L%:L%=LENA$:data%?0=0:data%?1=L%
  130 IF L%:FOR A%=2 TO L%+1:data%?A%=ASCMID$(A$,L%-A%+2,1):NEXT
  140 PROCgbpb(2,O%,data%,L%+2,0):ENDPROC
  150 :
  160 :
  170 REM PROCBBC_WrInt(out%,int%) - write integer to file
  180 REM On entry: out% - handle to output file
  190 REM           int% - integer to write
  200 REM ------------------------------------------------
  210 DEFPROCBBC_WrInt(O%,I%)
  220 data%!4=I%:data%?3=data%?5:data%?2=data%?6:data%?1=data%?7:data%?0=&40
  230 PROCgbpb(2,O%,data%,5,0):ENDPROC
  240 :
  250 :
  260 REM PROCBBC_WrReal(out%,real) - write real to file
  270 REM On entry: out% - handle to output file
  280 REM           real - real value to write
  290 REM -------------------------------------------------
  300 DEFPROCBBC_WrReal(O%,A)
  310 IF FALSE THEN
  320   PRINT#O%,A:ENDPROC
  330 ENDIF
  340 ?data%=&FF:|(data%+1)=A:PROCgbpb(2,O%,data%,6,0):ENDPROC
  350 :
  360 :
  370 REM PROCBBC_Rd(in%) - read value from file
  380 REM On entry: in%  - handle to input file
  390 REM On exit:  Reads the next item and returns int, real or string
  400 REM -------------------------------------------------------------
  410 DEFFNBBC_Rd(I%):LOCAL L%,A$,A:A%=BGET#I%
  420 IF A%=0:L%=BGET#I%:IF L%=0:=""
  430 IF A%=0:PROCgbpb(4,I%,data%,L%,0):L%=L%-1:REPEATA$=A$+CHR$data%?L%:L%=L%-1:UNTILL%<0:=A$
  440 IF A%=&40 OR A%=1:PROCgbpb(4,I%,data%,4,0):data%?4=data%?2:data%?5=data%?1:data%?6=data%?0:=data%!3
  450 IF FALSE THEN
  460   PTR#I%=PTR#I%-1:INPUT#I%,A:=A
  470 ENDIF
  480 PROCgbpb(4,I%,data%,5,0):=|data%