8

Someone recently commented that, "a shift-Return is really different from a normal one. It moves the cursor to the next line, but does not complete an input operation."

This would be interesting and perhaps convenient to have, but I tried it out in VICE on an emulated C64 running Commodore 64 BASIC V2 but the behaviour doesn't seem quite that, or at least doesn't make the subsequent line a continuation of the screen editor's logical input line, as far as I can tell. Below, » in the left margin indicates lines I typed, and at the end of a line indicates ShiftRETURN.

  READY.
» PRINT "HELLO↵
» WORLD"

  ?SYNTAX ERROR
  READY.

Using the arrow keys to move up to the "HELLO" line and pressing RETURN on it overwrites the following lines with HELLO, a blank line and READY..

A couple of other examples:

» 10 PRINT "HELLO↵
» WORLD"

  ?SYNTAX ERROR
  READY.
» LIST

  READY.

» A=1:B=2
» PRINT A↵
» PRINT B
  2

  READY.

In that last one, arrowing up to the PRINT A line and pressing RETURN on it overwrites the first two characters of the PRINT B line with 1, leaves the next line alone, and overwrites the line after that with READY..

So what is this feature, how does it work, and how is it intended to be used? Is it different on different versions of the Commodore screen editor and BASIC?

2 Answers 2

12

TL;DR:

It's a feature of how the Commodore screen editor and its connection to BASIC works. SHIFT-RETURN only advances the cursor on-screen. It does not change or manage logical lines. There is no implied line continuation.


The Long Story:

As assumed, it isn't a line continuation. In the examples given it essentially works like hitting CTRL-X on an Apple II: The actual line does not get executed and the cursor moves to the beginning of the next screen line.

While the Apple II (and many other BASIC machines) is based around a line input buffer, the Commodore uses a screen editor managing a series of logical lines. All editing is not done on screen lines, but these logical lines. They are created within the screen buffer whenever something is terminated with a return - either by entering text until return is hit, or when a program line gets output by LISTing it. This behaviour is the same since the very first PET. Something a Commodore user will learn to use early on when editing.

Within this context SHIFT-RETURN simply advances the cursor down one line and up to the leftmost column. It's strictly a cursor movement, exactly as if done with the arrow keys. Cursor movement does not change the management/structure of logical lines, but simply moves the cursor around the screen. Editing is done on the screen without BASIC. Return is the only key that hands over a logical line to BASIC.

The examples given do not use logical lines that spread over multiple screen lines, thus each of the lines entered is seen by the editor as a separate logical line.

  1. In the first example, the screen line with PRINT "HELLO is one logical line, but since it's left via cursor movement, it doesn't get extended to the next screen line. Thus WORLD" is put on a new logical line. When handed over to the BASIC cruncher it will of course generate a syntax error.

  2. Since no line number was ever handed to BASIC, no line is stored in the second example, resulting in LIST showing an empty program.

  3. Similarly in the third example. Here the first logical line (A=1:B=2) was sent to BASIC, the second (PRINT A) wasn't (no return), while the third (PRINT B) was again, with an obvious result.


Example to see the difference while still using single screen line logical lines, try to enter your previous sequence as lines:

» 10 A=1:B=2
» 20 PRINT A↵
» 30 PRINT B
» LIST

  10 A=1:B=2
  30 PRINT B
  READY.

Now move the cursor up to the original (first) line 10 and hit four times return (no shift), now all lines are in the program and will be listed:

↵ 10 A=1:B=2
↵ 20 PRINT A
↵ 30 PRINT B
↵ LIST

  10 A=1:B=2
  20 PRINT A
  30 PRINT B
  READY.

A good way to see if a logical line extends over multiple screen lines is to simply delete or insert a character, as the editor will only move what belongs to the logical line.

5

@raffzahn already answered with most of what I had in mind when I made that comment. Here are some additional things.

If you have a BASIC program like this

 10 INPUT "TYPE SOMETHING";A$
 20 PRINT "YOU TYPED ";A$

If you run this, and type something to the prompt, but then type a shift-return instead of a normal return, you will notice that the program does not continue. Only once you type a normal return it goes on. The text on the line where you typed return will be considered your response.

You would also see an interesting detail in how the INPUT command works in combination with the screen editor. When the INPUT starts, the kernel remembers the cursor's horizontal position. This is so that when you hit return, it can start returning the first character from that screen position, one by one, to the last non-space on the line. The characters are indeed plucked from the screen memory and converted to PETSCII for this!

If you move the cursor off the line, this start position is cleared, because it now makes no sense any more. Sometimes people accidentally type a cursor up or down at an INPUT prompt, and then correct it and go back to the line of the prompt. To their surprise, the prompt is now part of their resulting response. You get the same effect if you use shift-return to go to another line.

Like other control characters, shift-return would have a string representation. For example, Control-Q (cursor down) is (in a string) represented as a reverse-field Q. Let's write that as [Q]. Likewise, you can try to enter shift-return into a program:

 10 PRINT "STUFF [shift-M]MORE STUFF"

Except that you can't type it like other cursor control characters: shift-return is sufficiently special that when printing it, even in quote mode or insert mode, it is executed rather than printed as a control character. And using the screen editor involves a small loop that gets characters from the keyboard buffer and prints them according to the normal rules of printing.

So how do you type this line? It just takes two steps. First you type the line and leave a placeholder character instead of the [shift-M]. After you type the 2nd quote you're out of quote mode (or you can type return to get out of quote mode), and you can move the cursor back to the placeholder. Type RVS-ON, and then shift-M. This sort of fabricates the character in another way. Then you type return (again).

Now if you LIST this, you get to see how the [shift-M] gets executed, even between quotes, and not printed as [shift-M].

 10 PRINT "STUFF 
MORE STUFF"

This is actually fairly close to what you were trying to achieve in your question. There is just not an easy way to edit this line; you'll have to re-create it to change it.

You can try the same with a normal return: [M] instead of [shift-M].

The [M] works so well like when typing it, you only get the first part of the line. Basic's line input loop thinks it is done when it receives character number 13, the [M].

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .