Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

open/lines

 [1/4] from: ptretter:primary at: 14-Jan-2001 16:20


If I used open/line/direct/no-wait I get a block when doing a: copy port I get a string when I do: copy first port My question is how do I use copy port and convert it to get the same output that copy first provides in a string format without generating a past-end error. Paul Tretter

 [2/4] from: holger:rebol at: 14-Jan-2001 15:26


On Sun, Jan 14, 2001 at 04:20:43PM -0600, Paul Tretter wrote:
> If I used open/line/direct/no-wait I get a block when doing a: > > copy port > > I get a string when I do: > > copy first port > > My question is how do I use copy port and convert it to get the same output that copy first provides in a string format without generating a past-end error.
Here is the behavior for ports in line/direct/no-wait: copy returns a block of all lines waiting to be read, and removes them from the port buffer. Each element of the block is one line. If no lines are waiting then an empty block is returned. If the other end has closed the connection then none is returned. first port is a shortcut for "pick port 1". It returns the next line and removes it from the buffer. The result is none either if no data is pending (this will probably change in the next version) or if the end of the stream has been reached. You don't need to "copy" the result. If you want to be able to distinguish between no data and eof, but still want only a single line returnd to you at a time, then use "copy/part port 1". If the returned value is a block then it is either empty or has exactly one item in it, which you can access using "first". -- Holger Kruse [holger--rebol--com]

 [3/4] from: foodsafety::ains::net::au at: 15-Jan-2001 21:12


Try this: data: copy port incoming-str: either empty? data [""] [first data] or you could get it to return none, or run an error handler in the same manner. SpliFF Paul Tretter wrote:

 [4/4] from: ptretter:norcom2000 at: 14-Jan-2001 18:14


Thanks Holger, I was able to modify my script to include copy/part port 1 and then add some logic which got it working without a hitch and got rid of the past-end message. The logic was just an added line: if irc-input-buffer = block! [irc-input-buffer: to-string irc-input-buffer] Paul Tretter P.S. - This should probably get added to the /Core docs some day depending on how it changes in the next release. ----- Original Message ----- From: "Holger Kruse" <[holger--rebol--com]> To: <[rebol-list--rebol--com]> Sent: Sunday, January 14, 2001 5:26 PM Subject: [REBOL] Re: open/lines
> On Sun, Jan 14, 2001 at 04:20:43PM -0600, Paul Tretter wrote: > >
<<quoted lines omitted: 7>>
> > > > My question is how do I use copy port and convert it to get the same
output that copy first provides in a string format without generating a past-end error.

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted