cursor

Prev Next

Function Names

cursor

Description

The cursor will be moved to a specified position. The numeric parameters may be supplied as

  • Positive numbers
  • Negative numbers, which are converted to console width or height minus the specified number. For example, in a console showing 80 columns and 25 rows, -10 refers to column 70, and -5 refers to row 20.
  • If absolute cursor positions are expected (with 'column' option or two numeric coordinates supplied), fractional cursor positions related to the console size may be provided. The value must be greater than 0 and smaller than 1. For example, in a console showing 80 columns and 25 rows, a row = 0.4 moves the cursor to row 10, and a column of 0.25 moves the cursor to column 20.

Call as: procedure

Restrictions

Indirect parameter passing is disabled

OS differences

The consoles under Windows, LINUX and MacOS and even different console or terminal programs may show some deviating behaviors.

Parameter count

1-2

Parameters

No.TypeDescription
1
input
numeral X

Supply positive or negative or fractional numbers. 0 is treated like 1.
Negative values count from the right column (or bottom row) of the screen leftward (or upward). The current console size will be used. On a console showing 25 rows and 80 columns, the function call cursor(-20, -10) moves the position to colum 60 and row 15.
Positive fractional values greater than 0 and smaller than 1 are interpreted as relative position to full screen width. For example, a 0.75 applied to a console set for 80 characters moves the cursor to column 60.

Alt. 1
input
string Cursor navigation option

Alternative to specifying absolute positions, following cursor navigation keywords are supported where n refers to the value passed in the 1st function parameter. Unless specified otherwise, no scrolling takes place if attempting to move the cursor beyond the visible console view, even if contents are existing. The cursor stops at the left, right, top and bottom corners.

left Move cursor n columns to the left. See 1
right Move cursor n columns to the right See 1
up Move cursor n rows up Cursor movement stops at 1st visible row of the console. See 1
down Move cursor n rows down. Cursor movement stops at last visible row of the console. See 1
scroll up Scroll screen contents up. The cursor moves along with the scrolling contents, i.e. stays in the same text position. See 1
scroll down Scroll screen contents up. The cursor moves along with the scrolling contents, i.e. stays in the same text position. See 1
lines up Move cursor to 1st column and n rows up. See 1
lines down Move cursor to 1st column and n rows down. See 1
column Move cursor to column position n. Positive fractional values greater than 0 and smaller than 1 are interpreted as relative position to full screen width. For example, a 0.25 applied to a console set for 80 characters moves the cursor to column 20.
space below Ensures that n vacant rows are available below the cursor position. If not sufficient number of rows are available, then contents will scroll up. Example: Console has 25 rows. Cursor is at row 23. Calling cursor(space below, 4); scrolls the contents up by two rows to ensure 4 blank rows are available.
memorize Memorize current cursor position. The 2nd parameter will be ignored if specified. Only one position can be memorized at a time.
restore Restore memorized cursor position. It will only happen if the cursor position has been memorized before. The 2nd parameter will be ignored if specified.
hide Hide the cursor
show Show the cursor (again)

1 Oppositie direction (e.g. right instead of left) is taken if the number in the 2nd parameter is negative.

2
input
numeral Navigation value or Y

Row position. 0 (zero) will be ignored and no cursor action takes place. Negative numbers are supported.

Default value: 1

Exceptions

none

Examples

    savecode
    cursor( 5, 3 );
    print( "Text appears on row 3, column 5" );
    cursor( 1, previous )

Output

    Text appears on row 3, column 5