Thanks Atilla, I actually have a function for that which is more efficient:
rem Returns a section of the source string starting at 'pos' and extending 'wid' characters.
function midleft$(a$,pos,wid)
a$ = right$(left$(a$,pos+wid),wid)
endfunction a$
Some various string functions:
rem returns the text between the nth instances of head$ and tail$. (head$ and tail$ are single characters.)
function between$(source$,head$,tail$,n)
for x = 1 to len(source$)
if mid$(source$,x) = head$
open = 1
for y = x+1 to len(source$)
if mid$(source$,y) = tail$
dec open
if open=0
if n=0
ret$ = right$(left$(source$,y-1),y-x-1)
exitfunction ret$
else
dec n
endif
endif
endif
if mid$(source$,y) = head$ then inc open
next y
endif
next x
endfunction ""
`//
rem Returns the position of the nth instance of c$ within source$
function chrPos(source$,c$,n)
for x = 1 to len(source$)
if mid$(source$,x) = c$
if n=0 then exitfunction x else dec n
endif
next x
endfunction 0
`//
rem Returns a section of the source string starting at 'pos' and extending 'wid' characters.
function midleft$(a$,pos,wid)
a$ = right$(left$(a$,pos+wid),wid)
endfunction a$
`//
rem Returns the left- or right-most part of a string split at 'find$'.
rem 'find$' is omitted from the return string.
rem To split the source string at the first instance of 'find$',
rem give 'part' a value of 0 (to return left half) or 1 (to return right half).
rem if you wish to split the string at a further instance of 'find$' simply increase
rem 'part' by 2 for every instance you wish to ignore.
rem If the search fails the source string is returned.
function split$(s$,f$,part)
for x = 0 to len(s$)-len(f$)
if midleft$(s$,x,len(f$)) = f$
select part
case 0 : exitfunction left$(s$,x) : endcase
case 1 : exitfunction right$(s$,len(s$)-len(f$)-x) : endcase
case default : s$ = midleft$(s$,x+1,len(s$)) : dec part,2 : endcase
endselect
endif
next x
endfunction s$
`//
rem Returns the start-point of the nth instance of f$ within source$.
function strPos(source$,f$,n)
for x = 1 to len(source$)
if midleft$(source$,x,len(f$)) = f$
if n=0 then exitfunction x else dec n
endif
next x
endfunction 0
`//