VDU 13

From BeebWiki
Revision as of 00:03, 4 October 2007 by Beardo (talk) (LF before CR)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Moves the cursor to the start of the current line.

VDU 13
Syntax VDU 13
Keyboard equivalent RETURN or CTRL M
Character stream (hex) 0D
Description Moves the cursor to the start of the current line of the text window (usually the left edge but possibly the right edge under RISC OS.)

Description

VDU 13, or the RETURN key, represents 'carriage return'. The cursor moves to the beginning (usually the left edge) of the line it is on. So does the print head of an attached printer. Any characters they pass over are unaffected. The cursor does not move down the screen (a line feed is needed for that) but certain printers advance the paper as well.

While the computer is waiting for a command or for INPUT, pressing RETURN finishes the line; the input routine echoes the carriage return, preceded by a line feed to move the cursor down and show that input is complete.

As an output character, CR is useful for printing a status message that updates in-place without scrolling the screen:

10 PRINT "Processing..."
20 FOR I%=0 TO 100 STEP 10
30 PRINT CHR$(13);I%;" percent complete";
40 J%=INKEY(100)
40 NEXT
50 PRINT

-- beardo 00:03, 4 October 2007 (BST)