'14:20 24/05/2019

type string32
  string buf
end type

  macro string32_"move" (a,b)
   a.buf = b.buf
  end macro
  '
  macro string32_"+" (a,b,c)
    a.buf = b.buf + c.buf
  end macro
  '
  macro string32_"&" (a,b,c)
    a.buf = b.buf + c.buf
  end macro

function len( string32*ss ) as int
  return len(ss.buf)/4
end function

function str32( string s ) as string32
  int le=len(s)
  function.buf=nuls(le*4)
  byte a at strptr(function.buf) 
  byte b at strptr(s)
  int i 
  for i=1 to le
     a=b : @a+=4 : @b++
  next
end function

'#recordof str32

function AnsiStr( string32*s ) as string
  int le=len(s.buf)/4
  string t=nuls(le)
  byte a at strptr(t) 
  byte b at strptr(s.buf)
  int i 
  for i=1 to le
     a=b : @a++ : @b+=4
  next
  return t
end function

function left( string32*ss, int n ) as string32
  function.buf=left(ss.buf,n*4)
end function

function mid( string32*ss, int i,n ) as string32
  function.buf=mid(ss.buf,i*4-3,n*4)
end function

'TESTS
string q="abc"
string r
string32 s,t,u
s=str32(q)
'print len(s)
t=s+s
'print ansistr(t+s)
print ansistr(mid(t+s,4,5))
u=mid(t+s,2,3)
print ansistr u
r=ansistr(left(t,4))
print r
