Available on: c64 c64reu c128
See also: XPEN
Alias: Y PEN

YPEN

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

It is important to note that the YPEN 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 YPEN 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 YPEN (and usually also XPEN for the horizontal coordinate) in a continuous loop within the program.

The value returned by YPEN 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

 = YPEN( )


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

EXAMPLE

 x = YPEN( )


ABBREVIATION: Yp

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:

YPEN ↔ Yp

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