If you have text on the screen, you can read any character at the text cursor using the SWI "OS_Byte" 135.
This is the modern equivalent of the old *FX 135 (which still works).
In Basic, a typical call - made after the text cursor has been placed where you want it - would be:
SYS "OS_Byte",135 TO , asciichar%
That is, on exit, register R1 contains the ASCII code of the character at the cursor, and here it is assigned to the variable asciichar%.
If the character is unreadable then 0 is returned.
Any blank space on the screen, whether a space between words or somewhere where the screen is otherwise blank, returns the <space> character (32).
I have used this call successfully in a playing card selection routine and reader John Whitehead is using it to read words off the screen which have been presented by the *Anagram facility mentioned last time.
Incidentally, the same SWI call also returns, on exit, the screen mode in R2.
Source: | Archive Magazine - 12.10 - "Learners' Column" |
Publication: | Archive Magazine |
Contributor: | Ray Favre |