[img] Scrolling Input
 MDFS::Info.Comp.Spectrum.ProgTips.input/htm Search  

On most computers the INPUT command displays characters at the current print position, and as you enter additional lines the previous lines stay on screen and the input position scrolls downwards.

On the Spectrum, INPUT always uses the bottom lines of the screen. Once a line has been input, it is cleared and the next INPUT displays at the bottom of the screen again.

On the Spectrum you can write code to give the same effect as INPUT on other systems. The main disadvantages are that you have to write a complete editor, deal with adding and removing characters, process key-repeats and key-clicks all yourself. This is a lot of work, when almost everything is already available in the system ROM.

The code simulates the "normal" INPUT used on other systems. It works by increasing the size of the bottom input area enough to push the top of the bottom of the screen up to the same position as the current screen print position. The INPUT is then taken at the top of the bottom of the screen. After the INPUT, the entered string is then redisplayed. This example displays a "*" prompt before the input.

INPUT AT PEEK 23689-2,0;AT 0,0;"*";LINE a$
INPUT;:PRINT '"*";a$

To see what is happening, make the BORDER a different colour from the PAPER.

Best viewed with Any Browser Valid HTML 4.0! Authored by J.G.Harston
Last update: 18-Oct-2004