[Xerte] Escape sequences

Chris Peachment cpeachment at ononbb.com
Thu Jun 25 16:10:59 BST 2009


Youngsters are missing soooo much history these days.

Way back when I was an apprentice coder, we used
teletypewriters that had a keyboard in front of a line
printer. When typing lines into the "line editor" (what
else could it be called?), you pressed the carriage
return key, and, just like the old mechanical typewriters,
it had the effect of moving the print head back to the
left margin and also rolling the platen (and paper) up
one line.

So two actions, a carriage return and a line feed,
resulted from pressing one key on the keyboard.

When your program was outputting text to the printer
there were occasions when advancing the paper without
moving the print head was the desired action. And
there were times when moving the carriage back to the
left margin without advancing the paper was needed.

For these actions there needed to be two different
signals (i.e. control characters) sent to the printer.
When ASCII was defined, these signals were labelled
as "Carriage Return" (ASCII value 13 hex) and "Line
Feed" (ASCII value 10 hex).

I think it was when Kernighan and Ritchie designed the
'C' language, they specified the backslash as the escape
to control characters and English language nmemonics for
the desired actions:

	\r => return (0x13 or 13H)
	\n => new line (0x10 or 10H)
	\t => tab (0x08 or 08H)

plus others used less often.

To this day, we see consequences of other design decisions
made after screen editors became available. The UNIX (and
derivative) operating system designers chose just one
character to be sent when the "Enter" key was pressed and
the chose the "Line Feed". The Apple Mac designers chose
to use the "Carriage Return" as the single character.

The rest of the ASCII world stayed with two characters,
requiring both Carriage Return and Line Feed to remain
compatible across both screen and printer.

Hope that helps.


On Thu, 2009-06-25 at 15:42 +0100, Fred Riley wrote:
> Ah, right, I thought they'd be the standard escape sequences I know and
> love from PHP and elsewhere, but I'd not come across /r before. Thanks.
> 
> Fred Riley
> Learning Technologist
> School of Nursing, Midwifery and Physiotherapy, University of Nottingham
> Vcard: http://www.nottingham.ac.uk/nursing/sonet/about/fr_uon.vcf  
> 
> > -----Original Message-----
> > From: xerte-bounces at lists.nottingham.ac.uk 
> > [mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of 
> > Marc Torruella Altadill
> > Sent: 25 June 2009 15:33
> > To: 'Xerte discussion list'
> > Subject: RE: [Xerte] Escape sequences
> > 
> > Hi Fred,
> > What i use to use is \r\n, dunno why, just done it all my 
> > programming life :-).
> > If you wanna know the difference between \r and \n check what I found:
> > 
> > Source: http://www.htmlcodetutorial.com/help/ptopic1794.html
> > 
> > \n is a new line and \r is a carriage return
> > 
> > http://en.wikipedia.org/wiki/Newline
> > 
> > http://www.everything2.com/index.pl?node=newline
> > http://www.everything2.com/index.pl?node=carriage%20return
> > 
> > -----Mensaje original-----
> > De: xerte-bounces at lists.nottingham.ac.uk
> > [mailto:xerte-bounces at lists.nottingham.ac.uk] En nombre de 
> > Fred Riley Enviado el: jueves, 25 de junio de 2009 16:23
> > Para: Xerte discussion list
> > Asunto: [Xerte] Escape sequences
> > 
> > Just a couple of very minor queries, not problems, honest:
> > 
> > 1. In the app I'm working on, put together by someone else 
> > (see prior email), there's the following code:
> > 
> >   summary += texts[i] + '\r\r';
> > 
> > I take it that \r is an escape sequence, but what for? The 
> > two \r seem to generate a new line, but I'd have expected \n 
> > for that. Is there a help topic on the escapes available in Xerte?
> > 
> > 2. In a text icon the text simply reads:
> > 
> > {summary}
> > 
> > which displays a text variable built up in a previous script 
> > icon. If I add anything else to the text then the var ceases 
> > to display and I just see the string "{summary}". What are 
> > the rules for using this construct?
> > 
> > Just minor curiousities, no big, feel free to ignore :)
> > 
> > Cheers
> > 
> > Fred Riley
> > Learning Technologist
> > School of Nursing, Midwifery and Physiotherapy, University of 
> > Nottingham
> > Vcard: http://www.nottingham.ac.uk/nursing/sonet/about/fr_uon.vcf
> > _______________________________________________
> > Xerte mailing list
> > Xerte at lists.nottingham.ac.uk
> > http://lists.nottingham.ac.uk/mailman/listinfo/xerte
> > 
> > _______________________________________________
> > Xerte mailing list
> > Xerte at lists.nottingham.ac.uk
> > http://lists.nottingham.ac.uk/mailman/listinfo/xerte
> > 
> _______________________________________________
> Xerte mailing list
> Xerte at lists.nottingham.ac.uk
> http://lists.nottingham.ac.uk/mailman/listinfo/xerte



More information about the Xerte mailing list