Terminal control/Positional read: Difference between revisions

From Rosetta Code
Content added Content deleted
m (Fix categories)
Line 32: Line 32:


{{omit from|GUISS}}
{{omit from|GUISS}}

[[Category:Terminal Control]]

Revision as of 13:14, 22 August 2011

Terminal control/Positional read is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Determine the character displayed on the screen at column 3, row 6 and store that character in a variable.

BASIC

Locomotive Basic

<lang locobasic>10 LOCATE 3,6 20 a$=COPYCHR$(#0)</lang>

Amstrad CPC screen memory only stores pixels but no character information (as opposed to e.g. the C64), so the firmware routine (TXT_UNWRITE) called by BASIC works by trying to find a match between screen pixels and the shape of a currently defined character. If the character table or screen pixels in the area of the character are changed between writing and reading, COPYCHR$ will therefore fail.

ZX Spectrum Basic

<lang basic> 10 REM The top left corner is at position 0,0

20 REM So we subtract one from the coordinates
30 LET c$ = SCREEN$(5,2)</lang>

REXX

The REXX doesn't have any cursor or screen management tools, but some REXX interpreters have added the functionality via different methods.

Works with: PC/REXX

<lang rexx>/*REXX program demonstrates reading a char at specific screen location.*/

row=20 /*point to row twenty. */ col=55 /*point co column fifty-five. */ howMany=3 /*read a trio of characters. */

stuff=scrread(row,col,howMany) /*this'll do it. */

other=scrRead(40,55,2) /*same thing, but for row forty. */</lang>