Re: reading strings
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Sep 06, 2006
- 553 views
On Tue, 05 Sep 2006 19:45:02 -0700, Hayden McKay <guest at RapidEuphoria.com> wrote: >nb. After reading your post and doing some testing I found that my routine will >crash if 'atom lp' points to a 0. <snip> >but I should change routine to accomodate as follows. >}}} <eucode> >-- if loc then > if loc >= 1 then > chunk = chunk[1..(loc-1)] > else > chunk = {} -- return empty string. > end if ></eucode> {{{ This rang a few alarm bells. First question is what error message did you get, exactly, that this is supposed to fix? I expect it was an error in the peek, if lp was zero or pointed to a zero in memory which was not followed by 255 bytes of readable memory. The change might solve an error "slice end is xxx ", but I doubt you got that. What you might have done is by adding those 4 lines of code made sure that a zero was now followed by at least 255 bytes of readable memory (code). Note that chunk = chunk[1..0] is a valid Eu statement. If anything, I'd say that as it stands if you peek a 256-character string, with no terminator in it anywhere, it will return {}, or would have crashed before. Regards, Pete