Re: get() - GET_FAIL x GET_EOF
- Posted by Ted Fines <fines at macalester.edu> Apr 20, 2001
- 417 views
In get.e, the GET_ trio are defined as: global constant GET_SUCCESS = 0, GET_EOF = -1, GET_FAIL = 1 Try this code: include get.e puts(1,"ONE>" & sprintf("%d",value("{1,")) & "<ONE" & "\n") puts(1,"TWO>" & sprintf("%d",value("{1")) & "<TWO" & "\n") puts(1,"TRE>" & sprintf("%d",value("{1,2,")) & "<TRE" & "\n") puts(1,"FOR>" & sprintf("%d",value("{1,2")) & "<FOR" & "\n") puts(1,"FIV>" & sprintf("%d",value("{1,2}")) & "<FIV" & "\n") puts(1,"SIX>" & sprintf("%d",value("{A,")) & "<SIX" & "\n") I get this result: C:\>ex test ONE>-1<ONE TWO>1<TWO TRE>-1<TRE FOR>1<FOR FIV>0<FIV SIX>1<SIX This makes sense to me... I can see how the code would read the comma in ONE, expect another element, and not finding one return a GET_EOF. Whereas it merely fails with no closing curly bracket. Not that I'm justifying it, but I can see how it would work like this...Seems like it might make more sense if an ending comma or missing curly bracket would return the same result. Anyway, if the behavior is consistent, you should be able to find a way to work with it... Ted --On Friday, April 20, 2001 8:00 PM +0200 martin.stachon at worldonline.cz wrote: > > > > Slim down your email inbox. And firm up your newsletter flow > with My Topica's email newsletter organizer. It's free of > charge, free of calories. No dieting required! > > > Hi all > > why > value("{1,") gives GET_EOF, but > value("{1") gives GET_FAIL ? > > I'm writing chat program. The exchange of messages could be done with > sequences : client will send something like {myname,message,other_info}. > The server will read buffer and then decide : > > GET_SUCCES => process message > GET_FAIL => error, ignore this message, send warning to client > GET_EOF => whole message not sended yet, read the buffer again > > Should I use some special char after the end of sequence ? > > Thanks > ------------------------ > Regards, > Martin Stachon > >