Q(uick)BASIC Commands: Cursor-Movement

Quick View

Cursor Movement Commands

Initiate movement from the current graphics position

Worth knowing

Useful and cross-version information about the programming environments of QBasic and QuickBasic.

Description/Parameter(s)

The following prefix commands can precede any of the movement commands:

Prefix Description
B Move, but do not plot any points.
N Move, but return to original position when done.

The following commands specify movement in units. The default unit size is one point; this unit size can be modified by the S command, which sets the scale factor. If no argument is supplied, the cursor is moved one unit. (S is described in Angle, Color, and Scale-Factor Commands )

Each of the movement commands initiates movement from the current graphics position, which is usually the coordinate of the last graphics point plotted with another graphics macro-language command. The current position defaults to the center of the screen when a program is run.

Movement Description
U [n] Move up n units.
D [n] Move down n units.
L [n] Move left n units.
R [n] Move right n units.
E [n] Move diagonally up and right n units.
F [n] Move diagonally down and right n units.
G [n] Move diagonally down and left n units.
H [n] Move diagonally up and left n units.
M x,y Move absolute or relative. If x is preceded by a plus (+) or minus (-), the movement is relative to the current point; that is, x and y are added to (or subtracted from) the coordinates of the current graphics position and connected with that position by a line.
If no sign precedes x, the movement is absolute; that is, a line is drawn from the current cursor position to the point with coordinates x,y.
Description/Parameter(s)

Cursor movement commands initiate movement from the current graphics position, which usually is the coordinates of the last graphics point plotted with a DRAW macro-language command or another graphics command (such as LINE or PSET).

  • DRAW stringexpression$

Either of two prefix commands can precede any of the other movement commands in stringexpression$:

B Move, but do not plot any points.
N Plot, but return to original position when done.

The following commands specify movement in terms of n units:

  • The default unit size is one pixel.
  • Unit size can be modified by the S command, which sets the scale factor (see Rotation, Color, and Scale-Factor Commands ).
  • If no unit argument is supplied, the graphics cursor is moved one unit.
  • The cursor-movement commands have the following effect:
Command Effect
U[n] Move up n units.
D[n] Move down n units.
L[n] Move left n units.
R[n] Move right n units.
E[n] Move diagonally up and right n units.
F[n] Move diagonally down and right n units.
G[n] Move diagonally down and left n units.
H[n] Move diagonally up and left n units.
M[{+|-}]x,y Move absolute or relative:
  • If x is preceded by a plus (+) or minus (-), the movement is relative to the current point. The x and y are added to (or subtracted from) the coordinates of the current graphics position and movement is to that point.
  • If no sign precedes x, the movement is absolute. Movement is from the current cursor position to the point with coordinates x, y.

Usage Notes

  • The current position defaults to the center of the screen when a program begins execution.