Window output (Documentation Bugs and Problems)

by Jim ⌂ @, Russell, KY, Sunday, February 17, 2013, 22:27 (2379 days ago) @ lrcvs

Actually the EXPLODE function is acting correctly. If the delimiter was a comma like in the string "a,,c,,,f" this should be an array of six items with three of them the empty string. In your example the spaces are delimiters and there are words of zero length between the spaces.

Your code is trimming the leading and trailing spaces and removing the duplicates (as mine is below) but that is not the behavior I was expecting. I guess the documentation should be updated to reflect the possibility of zero length strings being between the delimiters.


z$ = " while AZUCAR for next AGUA VINO$ and input"
y$ = cleandelim$(z$," ")
print "long = " + string ( length (y$))
w$ = explode(upper (y$)," ")
print "words in w$ = " + w$[?]
print "ERROR !!!, there is = " + w$[?]
for n= 0 to w$[?]- 1
print w$[n]
next n
print ":::::::::::::::::::::::::::::::::::::::::::"

function cleandelim$(s$, delim$)
# remove duplicate, leading and trailing delimiters
y$ = s$
y2$ = y$
y$ = replace(y2$,delim$+delim$,delim$)
until y$ = y2$
if left(y$,1) = delim$ then y$ = mid(y$,2,length(y$)-1)
if right(y$,1) = delim$ then y$ = left(y$,length(y$)-1)
return y$
end function

Complete thread:

 RSS Feed of thread

powered by my little forum