1. puts() quirk
- Posted by "Bruce M. Axtens" <bruce_axtens at sil.org> Apr 23, 2003
- 465 views
Dear List I don't know if anyone's noticed this before ... maybe it's old news. sequence a sequence b a = { 'c', 'a', 't', 0, 0, 0 } b = "dog" puts( 1, a & "\n" ) puts( 1, b ) This outputs catdog Rather than cat dog As one might expect. Indeed, if one combines the puts() into one, e.g. puts( 1, a & "\n" & b ) then the program outputs cat Weird. Bruce. (Windows 2000 Advanced Server, Euphoria 2.4 beta, DOS32 script in a CMD.EXE window)
2. Re: puts() quirk
- Posted by Sabal.Mike at notations.com Apr 23, 2003
- 421 views
Actually, this makes perfect sense. Strings in most C-based modern languages are null terminated. Any bytes after the null are considered garbage and thus not part of the string. Since Euphoria's string handling is largely based on C routines, the first puts will see "cat\0\0\0\n", will see the first null (\0) and will stop the string at that point. Since it never saw the newline, it never printed it. The same is true for your second example. HTH, Mike Sabal >>> bruce_axtens at sil.org 04/23/03 04:53AM >>> Dear List I don't know if anyone's noticed this before ... maybe it's old news. sequence a sequence b a = { 'c', 'a', 't', 0, 0, 0 } b = "dog" puts( 1, a & "\n" ) puts( 1, b ) This outputs catdog Rather than cat dog As one might expect. Indeed, if one combines the puts() into one, e.g. puts( 1, a & "\n" & b ) then the program outputs cat Weird. Bruce. (Windows 2000 Advanced Server, Euphoria 2.4 beta, DOS32 script in a CMD.EXE window) TOPICA - Start your own email discussion group. FREE!
3. Re: puts() quirk
- Posted by "C. K. Lester" <cklester at yahoo.com> Apr 23, 2003
- 416 views
What is going on with Topica that it's cutting off the top of all the emails?!?!? In case you don't get the above line, I'll repeat it below... What is going on with Topica that it's cutting off the top of all the emails?!?!? What is going on with Topica that it's cutting off the top of all the emails?!?!? What is going on with Topica that it's cutting off the top of all the emails?!?!? What is going on with Topica that it's cutting off the top of all the emails?!?!? What is going on with Topica that it's cutting off the top of all the emails?!?!? What is going on with Topica that it's cutting off the top of all the emails?!?!? What is going on with Topica that it's cutting off the top of all the emails?!?!? What is going on with Topica that it's cutting off the top of all the emails?!?!? What is going on with Topica that it's cutting off the top of all the emails?!?!? What is going on with Topica that it's cutting off the top of all the emails?!?!? What is going on with Topica that it's cutting off the top of all the emails?!?!? What is going on with Topica that it's cutting off the top of all the emails?!?!? What is going on with Topica that it's cutting off the top of all the emails?!?!? What is going on with Topica that it's cutting off the top of all the emails?!?!? What is going on with Topica that it's cutting off the top of all the emails?!?!? What is going on with Topica that it's cutting off the top of all the emails?!?!? What is going on with Topica that it's cutting off the top of all the emails?!?!? ----- Original Message ----- From: <Sabal.Mike at notations.com> To: "EUforum" <EUforum at topica.com> Sent: Wednesday, April 23, 2003 7:50 AM Subject: Re: puts() quirk > HTH, > Mike Sabal > > >>> bruce_axtens at sil.org 04/23/03 04:53AM >>> > Dear List > > I don't know if anyone's noticed this before ... maybe it's old news. > > sequence a > sequence b > > a = { 'c', 'a', 't', 0, 0, 0 } > b = "dog" > > puts( 1, a & "\n" ) > puts( 1, b ) > > This outputs > catdog > Rather than > cat > dog > As one might expect. > > Indeed, if one combines the puts() into one, e.g. > puts( 1, a & "\n" & b ) > then the program outputs > cat > > Weird. > > Bruce. > (Windows 2000 Advanced Server, Euphoria 2.4 beta, DOS32 script in a > CMD.EXE window) > > > TOPICA - Start your own email discussion group. FREE! > > > > TOPICA - Start your own email discussion group. FREE! > >
4. Re: puts() quirk
- Posted by Robert Craig <rds at RapidEuphoria.com> Apr 23, 2003
- 428 views
Bruce M. Axtens wrote: > I don't know if anyone's noticed this before ... maybe it's old news. > > sequence a > sequence b > > a = { 'c', 'a', 't', 0, 0, 0 } > b = "dog" > > puts( 1, a & "\n" ) > puts( 1, b ) > > This outputs > catdog > Rather than > cat > dog > As one might expect. Yes, that's old news. If you want to output 0's, you should open a file in "wb" (binary mode) and write to it. File 1 (standard output) is opened in "w" mode (text mode), and it doesn't handle 0's as you'd like. Also \n is converted to \r\n which you might not like either. Someone recently asked for a routine to force standard output into binary mode, and I'm looking into it. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
5. Re: puts() quirk
- Posted by Juergen Luethje <j.lue at gmx.de> Apr 23, 2003
- 427 views
These lines may be deleted by Topica ... Hello Bruce, you wrote: > I don't know if anyone's noticed this before ... maybe it's old news. > > sequence a > sequence b > > a = { 'c', 'a', 't', 0, 0, 0 } > b = "dog" > > puts( 1, a & "\n" ) > puts( 1, b ) > > This outputs > catdog > Rather than > cat > dog > As one might expect. > > Indeed, if one combines the puts() into one, e.g. > puts( 1, a & "\n" & b ) > then the program outputs > cat > > Weird. A byte with value 0, and all other bytes after that in the argument of puts(), are ignored by the console window. AFAIK that is the standard behaviour of the console output. > Bruce. > (Windows 2000 Advanced Server, Euphoria 2.4 beta, DOS32 script in a > CMD.EXE window) Best regards, Juergen -- /"\ ASCII ribbon campain | \ / against HTML in | Money is the root of all evil. X e-mail and news, | Send 20 Dollars for more info. / \ and unneeded MIME |