This function returns the X-coordinate of the current cursor position.

Syntax

int WhereX(void);

Parameters

None

Return value

Returns the current X coordinate of the cursor position.

Remarks

The coordinates of the top left corner of the display are (0,0).
For information on the max value of this function.
XMax
TINY_FONT_X_MAX 21
SMALL_FONT_X_MAX 16
MEDIUM_FONT_X_MAX 21
LARGE_FONT_X_MAX 16
HUGE_FONT_X_MAX 10

Requirements

Header file:
lib.h
Library file:
libSTARTUPOPH5000.a

Sample

#include <stdio.h>
#include "lib.h"

#define MAXY 7 
void Move(void)
{
    int x, y;
    // Move the 'X" one place down and two places to the right.
    x=WhereX();
    y=WhereY();
    PrintSymbol(' ');
    x+=2;
    if (x > 15)
        x = 0;
    if (++y > MAXY)
        y = 0;
    GotoXY(x, y);
    PrintSymbol('X');
}
void main(void)
{
    Cursor(OFF);
    PrintSymbol('X');
    for(;;)
    {
        switch (getchar())
        {
        case TRIGGER_KEY:
            Sound(TSTANDARD,VMEDIUM,SHIGH,0);
            Move();
            break;
        case ENT_KEY:
            return;
        default:
            break;
        }
    }
}

Last updated: 2020/10/02