BBC BASIC for Windows
« Graphics Cursor Position »
Welcome Guest. Please Login or Register. Apr 5th, 2018, 11:10pm
ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018. Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.
If you require a dump of the post on your message board, please come to the support board and request it.
Graphics Cursor Position
« Thread started on: Nov 19th, 2011, 12:17pm »
How do you detect what character there is in a certain position, but the text is written at the graphics cursor position, not the text cursor position? GET doesn't work...
How do you detect what character there is in a certain position, but the text is written at the graphics cursor position, not the text cursor position? GET doesn't work...
Simple answer - you can't!
More complicated answer - sometimes you can, but not always! If you know the coordinates at which a character was plotted you can convert them to a text row and column (you need to take into account the current ORIGIN, the height of the graphics viewport, the average width and height of the currently selected font etc.). Having got a corresponding row and column you can use GET(x,y) which may return the character.
However it's not reliable, because (with a proportional-spaced font) at least two narrow characters (e.g. a lowercase ij) will fit in the width of a single text 'column'. So GET(x,y) can only return a single character, not both of them.
If you happen to be plotting a monospaced font in VDU 5 mode (which is not particularly common) then you should in principle be able to read the text back reliably using GET so long as you can calculate the corresponding row and column accurately (this assumes that the text viewport and the graphics viewport are overlapping).