Hi all, I wish to test a character to see if it is equal to the end-of line character. (In Java this would be c == '\n'). How does one do this in Oberon? I tried ch = DX where D is the hexadecimal value for carriage return, but I got a compiler error. E.
I wish to test a character to see if it is equal to the end-of line character. (In Java this would be c == '\n'). How does one do this in Oberon? I tried
ch = DX
where D is the hexadecimal value for carriage return, but I got a compiler error.
Try ch = 0DX. All (hexadecimal-)numbers need to start with "0".."9". The compiler thinks DX is a name, 0DX will be recognized as CHR(13). --Thomas
-----Original Message----- From: oberon-bounces@lists.inf.ethz.ch [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of Eric Sent: Sunday, 4 February 2007 10:59 AM To: oberon@lists.inf.ethz.ch Subject: [Oberon] literal value for end of line character?
Hi all,
I wish to test a character to see if it is equal to the end-of line character. (In Java this would be c == '\n'). How does one do this in Oberon? I tried
ch = DX
where D is the hexadecimal value for carriage return, but I got a compiler error.
That should be: IF ch = 0DX .... with a leading zero to signify that it is a numeric value to distinguish it from an identifier. Note: 1. 0DX (13 decimal) is actually an ASCII CR (carriage return) character. An ASCII LF (line-feed character) is 0AX (10 decimal). 2. Conventionally on Unix systems end-of-line is just LF and on MS-DOS heritage systems end-of-line is a CR-LF pair. 3. I don't know about Java but in C, '\n' is an LF character. Chris Burrows CFB Software http://www.cfbsoftware.com/gpcp
Chris Burrows skrev: [...]
3. I don't know about Java but in C, '\n' is an LF character.
Actually it's the other way around; In Java, '\n' is guaranteed to be 0A but in C, '\n' is not required to represent 0A. See also http://en.wikipedia.org/wiki/Newline. August
participants (5)
-
August Karlstrom -
Chris Burrows -
Eric -
Jörg Straube -
Thomas Frey