IonicWind Software

IWBasic => General Questions => Topic started by: JoaoAfonso on February 26, 2008, 03:16:00 PM

Title: End of line characters
Post by: JoaoAfonso on February 26, 2008, 03:16:00 PM
Ahoy. I am finding it amuzing writing this post in a bar using my PDA:> But this doubt arised and I'm affraid to forget it.

In other foruns I was speaking about a net program figuring out an EOF of a client connecting to it and sending info. I was told I should check all the usual different clients EOF, such as telnet. I was told I should check  \r, \n, \r\n, \n\r and \0 (different clients EOL markers). Figured out how to represent this in EB: \r and \n are for chr$(13) and chr$(10), meaning ENTER or new line. How to represent in EB, though, \0? Is there any EOF marker I am missing?

Thanks in advance
Title: Re: End of line characters
Post by: billhsln on February 26, 2008, 04:24:55 PM
Normally in most TEXT type files (not Binary's), the EOF char is Chr$(27), Control Z.

Bill
Title: Re: End of line characters
Post by: JoaoAfonso on February 26, 2008, 06:39:39 PM
nodnod, remembered the copy con command, to create bat files, which ending was the control Z (am I wrong?).
Thanks for the tip. Is there any other EOL I should be aware of? The /0 would be what?
Title: Re: End of line characters
Post by: billhsln on February 26, 2008, 08:43:55 PM
If I remember right /0 is a C convention to tell you when you have gotten to the end of a string.  Which is why ISTRING must be 1 longer then the maximum length you expect it to be (it has to have a /0 at the end).  I am not sure, but I think STRING ends the same way, but STRING has a max of 256 chars.

Bill
Title: Re: End of line characters
Post by: Ionic Wind Support Team on February 26, 2008, 09:15:11 PM
NULL is never used as an end of line marker in any text format I am aware of.  Unless it's a very old format from before my time.

You can directly use newlines in Emergence with the escape \n

"line one\nline two"

Paul.
Title: Re: End of line characters
Post by: JoaoAfonso on February 27, 2008, 07:36:22 AM
Hey.
Just checked and really works with \n. Anyway, what I need is try to identify the EOL of multiple clients so everyone can connect. Using instr to find chr$(10), chr$(13), chr$(27) or even "\n" is easy. I believe it might cover everything, but already dunno about a \0. This means NULL character? If yes, Paul already answered me. Can't remember about other EOL?
Title: Re: End of line characters
Post by: barry on February 27, 2008, 08:27:34 AM
The End of line character depends on the OS and to some extent on the language you're using.  Unix/Linux systems use /n.  Microsoft's systems (Windows and DOS) use /n/r.  A lot of languages, C and Ebasic among them, convert the /n/r to a /n to keep programming simpler.  That's one of the reasons you tell the compiler you're dealing with a text file.

This began with teletypes which used a /n/r, /n telling the teletype to go to the next line and /r telling it to go to the beginning of the line.  Both were needed.  Unix simplified this since in a screen or printer they would always be used together anyway.  DOS grew out of CP/M which used the telletype method intact and Windows followed suit.

I began programming in the days before computers had screens and the console was a teletype.  That was close to 50 years ago so I could remember some of it wrong. :)

Printers in those days were controlled with paper tape bands that had holes punched in columns and the programmer could send a code telling it to go to the position of the hole in a certain column.  The computer's operator had instructions about which tape band to use for any given printout.

Barry
Title: Re: End of line characters
Post by: LarryMc on February 27, 2008, 11:57:34 AM
Quote from: barry on February 27, 2008, 08:27:34 AM
....console was a teletype...
.. controlled with paper tape bands that had holes punched in columns.

I still have one of those old teletype machines that worked like that in a storage shed.
the 1st conputer I ever wirewrapped together used that as the output device.

Larry
Title: Re: End of line characters
Post by: JoaoAfonso on February 28, 2008, 02:58:25 AM
QuoteThe End of line character depends on the OS and to some extent on the language you're using.

That is the point of trying to work with all different kinds of EOL. Anyone should be able to connect to my program, using Windows, Linux or whatever.
Concerning programming, and to try to define the commands someone is sending to my program, I should use "instr" in search for all those EOL types. Then I use left$(command line,instr figured out before). Finally I could understand how that worked... some clients end with \n\r, others with \r\n, others with just \n... Just implemented the chr$(27), and I keep trying to check if there are more.
Thanks for all tips