'15:59 27/02/2025
'
'STRING STORAGE BUFFER
'for printing in one go
'and other uses
'
============
class buffer
============
'
bstring prbuf 'string buffer
int    pri    'index in prbuf
int    lw     'length of prw
'
method in(string prw)
---------------------
  int lw=len(prw)
  while len(prbuf) < pri+lw
    prbuf+=nuls 1024  'extend prbuf size
  wend                '
  mid prbuf,pri+1,prw 'patch in prw
  pri+=lw             'shift the index
end method
'
method clear()
--------------
  'CLEARING THE UFFER TO USE AGAIN
  pri=0    'reset the index
 'prbuf="" 'necessary when using instr to search.
end method
'
method read() as string
-----------------------
  method=left prbuf,pri
end method
'
method out() as string
----------------------
  method=read
  clear
end method
'
method constructor()
--------------------
  clear
end method
'
method destructor()
-------------------
  clear
  del prbuf
end method
'
end class

=======
'TEST:
=======

new buffer pr
pr.in "Hello" " "
pr.in "world"
pr.in "!"
print pr.out
'
del pr
'
