To use this file copy and paste this:
// #URL-lib "http://pin1.org/forthlib/flb/General/strings.flb" into BV Terminal 3
or here to download.
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// A collection of useful words for dealing wth Forth strings
// a forth string is a series of consecutive bytes terminated
// with a 0
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// HISTORY:
// Dec 2008 Added strcopy$
// REQUIRES:
// does not depend on any other files.
// CONSTANTS:
// none defined but words in the file use local variables.
Full Contents of File
: mid$ 
v$:  b  81
        offset  len  +    str  length  >  abort"  Mid$  outside  limits"
        str  offset  +  %@  b  len 
        move                                   
        0  %@  b  len  +  c!             
        %@  b                               
;
: strcopy$
        max-len  for               
                i  str1  +  c@ 
                dup  0=  if  drop  unloop  escape  then
                i  str2  +  c!
        next
;               
: add$
v$:  buff  162         
int:  len
        str1  length  =>  len   
        str1  %@  buff  len  move 
        str2  %@  buff  len  +  str2  length  1+ 
        move
        %@  buff             
;
: hl-number   
      str  offset  len  mid$       
      s"  &"  swap  add$               
      ?number    -1  <>  abort"  number  expected"
;
: instr$   
int:  count
        begin
                start  string  +  count  +
                c@    dup  ch  <>  swap  0  <>  and 
        while
                1  +>  count
        repeat
        start  string  +  count  +  c@
        0=  if  0  else  count  then
;
: tab   
v$:  buf  80
int:  count
        80  address  +  address
        do
                i  c@  dup  ch  =  swap  0  =  or 
                if
                        0  %@  buf  count  +  c! 
                        %@  buf    count         
                        leave
                else
                        i  c@
                        %@  buf  count  +  c! 
                        1  +>  count
                then
        loop
;