Re: Errors in function trim() (ESL0.01)
- Posted by don cole <doncole at pacbell.net> Mar 28, 2006
- 468 views
This one of the first routes I wrote when I started Euphoria a long time ago. </eucode> {{{ global function del_trail(object line) -- delete trailing whitespace if length(line)<2 then return " " end if while find(line[length(line)], " \t\n" ) do--WHITE_SPACE line = line[1..length(line)-1] end while return line end function global function trim(object line) if sequence(line) and length(line)>0 then -- delete any leading whitespace while find(line[1], " \t\n") do line = line[2..length(line)] if length(line) = 0 then exit end if end while end if if sequence(line) and length(line)>0 then -- delete trailing whitespace while find(line[length(line)], " \t\n") do line = line[1..length(line)-1] end while end if return line end function </eucode> {{{ Don Cole