Contains the current horizontal position of the cursor.
contains the current horizontal position of the cursor. As characters are written to a device, Caché updates $X
to reflect the horizontal cursor position.
Each printable character that is output increments $X
by 1. A carriage return (ASCII 13) or form feed (ASCII 12) resets $X
to 0 (zero).
is a 16-bit unsigned integer.
On non-Unicode systems, $X
wraps to 0 when its value reaches 65536. In other words, if $X
is 65535, the next output character resets it to 0.
On Unicode systems, $X
wraps to 0 when its value reaches 16384 (the two remaining bits are used for Japanese pitch encoding).
You can use the SET
command to give a value to $X
. For example, you may use special escape sequences that alter the physical cursor position without updating the $X
values. In this case, use SET
to assign the correct values to $X
after you use the escape sequences.
The following table shows the effects of different characters on $X
||Effect on $X
|Any printable ASCII character
|Nonprintable characters (such as escape sequences)
||See Using Caché ObjectScript.
The S(ecret) protocol of the OPEN
commands turns off echoing. It also prevents $X
from being changed during input, so it indicates the true cursor position.
Using WRITE *
, you can send a control sequence to your terminal and $X
will still reflect the true cursor position. Since some control sequences do move the cursor, you can use the SET
command to set $X
directly. For example, the following commands move the cursor to column 20 and line 10 on a Digital VT100 terminal (or equivalent) and set $X
ANSI standard control sequences (such as escape sequences) that the device acts on but does not output can produce a discrepancy between the $X
values and the true cursor position. To avoid this problem use the WRITE *
(integer expression) syntax and specify the ASCII value of each character in the string. For example, instead of using:
use this equivalent form:
As a rule, after any escape sequence that explicitly moves the cursor, you should update $X
to reflect the actual cursor position.
$X with TCP and Interprocess Communication
When you use the WRITE
command to send data to either a client or server TCP device, Caché first stores the data in a buffer. It also updates $X
to reflect the number of characters in the buffer. It does not include the ASCII characters <RETURN> and <LINE FEED> in this count because they are considered to be part of the record.
If you flush the $X
buffer with the WRITE !
command, Caché resets $X
to 0 and increments the $Y
value by 1. If you flush the $X
buffers with the WRITE #
command, Caché writes the ASCII character <FORM FEED> as a separate record and resets both $X