Available on: c64 c64reu c128
See also: YPEN
Alias: X PEN

XPEN

The XPEN command is used to query the hardware and get the horizontal position (X coordinate) of a light pen attached to the system, if the hardware supports such a device. When the ''XPEN' command is executed within a program, the underlying hardware attempts to read the X coordinate value detected by the light pen. This value represents the horizontal position of where the pen is currently pointing on the screen or a touch-sensitive surface.

It is important to note that the XPEN command will only work if the hardware on which the program is running actually has a pen interface, and if the pen is properly connected and working. If the hardware does not support a pen, the value returned by XPEN may be undefined (often 0 or some other default value), and will not represent a valid position.

On some systems, a pen calibration step may be necessary to ensure an accurate correspondence between the physical position of the pen and the coordinates on the screen. The language itself does not handle calibration directly, which is usually handled by the operating system or hardware-specific routines.

To track the movement of the pen, you will need to read the value of XPEN (and usually also YPEN for the vertical coordinate) in a continuous loop within the program.

The value returned by XPEN represents the horizontal coordinate. The range of these values will depend on the horizontal resolution of the screen or touch surface supported by the pen.

SYNTAX

 = XPEN( )


Legend
  • id : identifier
  • type : datatype
  • v : value
  • "..." : string
  • [...] : optional

EXAMPLE

 x = XPEN( )


ABBREVIATION: Xp

Join BASIC 10Liner Contest with ugBASIC!

An interesting competition is held at the beginning of each year: the BASIC 10Liner Contest. It is possible to use ugBASIC to participate in the next "BASIC10Liner" competition, in the following categories:

  • PUR-120 - A game in 10 lines of max 120 characters (w/abbrev.)
  • EXTREME-256 - A game in 10 lines of max 256 characters (w/abbrev.)
  • SCHAU - Any program in 10 lines of max 256 characters (w/abbrev.)
In order to reduce space you can use this abbreviation for this instruction:

XPEN ↔ Xp

Any problem?

If you have found a problem with this keyword, if you think there is a bug or, more simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!

open an issue BACK TO KEYWORDS