Re: reading strings
Hayden McKay wrote:
> }}}
<eucode>
> --==============================================--
> constant
> --
> TERMINATOR = 0, -- the string terminator
> MAXLENGTH = 256 -- maximum string length
>
> --------------------------------------------------
> -- changes...
> -- function now returns "{}" if the string
> -- is empty or the terminator is not found
>
> global function string(atom lp)
>
> sequence chunk
> integer loc
>
> chunk = peek({lp, MAXLENGTH})
>
> loc = find(TERMINATOR, chunk)
>
> -- if loc then
> if loc >= 1 then
> chunk = chunk[1..(loc-1)]
> else
> chunk = {} -- return empty string.
> end if
>
> return chunk
>
> end function
> </eucode>
{{{
Hayden:
Try this one.
constant
TERMINATOR = 0, -- the string terminator
MAXLENGTH = 256 -- maximum string length
--
global function string(object lp)
if atom(lp) then
return string(peek({lp, MAXLENGTH}))
else
return lp[1..find(TERMINATOR,lp)-1]
end if
end function
Bernie
My files in archive:
WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API
Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
|
Not Categorized, Please Help
|
|