console

Prev Next

Function Names

console

Description

This function provides following information:

1st parameter Functzionality
width Returns the width of console in number of chracters
height Returns the height of console in number of rows
x cursor Returns horizontal cursor position, beginning with 1
y cursor Returns vertical cursor position, beginning witj 1
x text Returns horizontal text position (number of characters printed are counted by B4P), beginningg with 1. The value may be bigger than 'x cursor'.
y text Returns vertical text position (number of line breaks are counted by B4P), beginningg with 1. Te value may be bigger than 'y cursor'.
row Returns absolute row number (positive integer) from specified row number where positive, negative and fractional numbers are supported.
column Returns absolute column number (positive integer) from specified column number where positive, negative and fractional numbers are supported.

Negative columns count from right to left. For a console with 80 characters, a -10 would translate to column 70.
Negative rows count from bottom up. For a console with 25 lines, a -1 refers to the bottom row (25), -2 one row up, etc.
Fractional numbers must be greater than (but not equal to) 0 and smaller than (but not equal to) 1. 1 refers to the last column (or row), and 0.5 to the middle.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

1

Parameters

No.TypeDescription
1
input
string Attribute

Following attributes are supported: width and height.

Opt. 2
input
numeral Position

For attributes 'row' and 'column' a 2nd parameter is needed to provide the original row or column specification which may also be negative or fractional numbers. For all other attributes, this second parameter will be ignored.

Default value: 1

Return value

TypeDescription
numeral Console width or height

number of characters per row or number of visible rows.

Examples

    echo( "Console has ", console(width),  " characters");
    echo( "Console has ", console(height), " rows");

Output

Console has 80 characters
Console has 24 rows
Try it yourself: Open LIB_Function_console.b4p in B4P_Examples.zip. Decompress before use.