Endless Loop

new topic     » topic index » view thread      » older message » newer message

Well I've done it again. I've gotten myself in a mess that only the
gallant heroes of the Euphoria for DOS Mailing List can fix. Below is
source for a routine I'm writing. I found out through the with trace
statement that I'n an endless loop, BUT I can't figure out why.
Someone PLEASE tell me where I'm misreading code. Thanks a bunch
guys.

with trace

--test.ex

include test.e
sequence test, test_1
test = "Joseph Martin"
trace(1)
test_1 = nospace(test)
printf(1, "%s", {test_1[1]})

--test.e

global function nospace(sequence s1)
        sequence s2
        atom space, n, x, y
        space = 1
        n = 0

        while space != 0 do
                space = find(32, s1)
                        if space = 0 then
                                return{s2}
                        else
                                        n = space - 1
                                        s2 = s1[1..n]
                                        x = space + 1
                                        y = length(s1)
                                        s2 = s2 & s1[x..y]
                        end if
        end while
        return{s2}
end function

~~>Joseph Martin
~~>Personal: joe at cyber-wizard.com
~~>Web:  jam.net at poboxes.com
~~>URL: http://users.exis.net/~jam/

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu