Dear all,
I tried using the Split function in an RBScript. It does not work. This
does not makes sense to me.
I tried:
Dim flds, fields() As String
flds="some string with spaces"
fields=flds.Split(" ")
This results in RBScript errornr 67 along with nr 2
I then created a method in the Context class:
Function cSplit(txtstring As String, txtsep As String) As String()
Return txtstring.Split(txtsep)
End Function
...and tried calling it in the RBScript as follows:
fields=cSplit(flds," ")
Same result. No go.
I really want to avoid stuff like countfields and nthfield, but -at
least as far as nthfield is concerned- there seems no other option than
to replace what could have been a one-liner with:
//Avoid the use of countfields
n=0
i=instrb(flds," ")
while i>0
n=n+1
i=instrb(i+1,flds," ")
wend
//No avoiding nthfield tho :-(
for i=0 to n+1
fields(i)=flds.nthfield(" ",i)
next
This does work, but makes use of nthfield, which I'd rather avoid, plus,
the code is more complicated.
Does anyone have some helpful comments on this?
1. I am curious as why something fundamental as Split doesn't work in
RBScript (not meant as criticism, I just want to understand).
2. Why does calling a function in the context which returns an array not
work?
3. Is there a better (read: faster) alternative to the one I came up with?
Thanks in advance,
Ronald Vogelaar
http://www.rovosoft.com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|