QB64.com

QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

The LOCATE statement locates the screen text row and column positions for a PRINT or INPUT procedure.

Syntax

LOCATE [row%][, column%] [, cursor%][, cursorStart%, cursorStop%]

Parameter(s)

Description

Example(s)

Moving the cursor around (now you can finally create a Commodore 64 emulator!). Default SCREEN 0 only:


crx = 10
cry = 10
DO
  LOCATE cry, crx, 1, 0, 8
  a$ = INKEY$
  SELECT CASE a$
     CASE CHR$(0) + "H": IF cry > 1 THEN cry = cry - 1 'up
     CASE CHR$(0) + "P": IF cry < 25 THEN cry = cry + 1 'down
     CASE CHR$(0) + "K": IF crx > 1 THEN crx = crx - 1 'left
     CASE CHR$(0) + "M": IF crx < 80 THEN crx = crx + 1 'right
     CASE CHR$(27): END
  END SELECT
LOOP 

Explanation: The CHR$(0) + “H”, “P”, “K”, “M” represents the cursor arrow keys. start = 0, stop = 8 is the tallest cursor, experiment with the start and stop values for different effects (start = 8, stop = 8 is the default producing a _ cursor).

See Also