Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I read characters from the screen?
#3
(05-05-2022, 10:02 PM)Pete Wrote:
(05-05-2022, 09:16 PM)hanness Wrote: Assume that I am initializing my display like this:

        _FullScreen _Off , _Smooth
        _FreeImage oldimage&
        Font& = _LoadFont(FontPath$, FontSize, "MONOSPACE")
        _Font Font&

Now I write a bunch of text to the screen.

Later, I want to read the character at the upper left of the screen. I tried to do this like this:

print screen(1,1)

or

MyVar$ = CHR$(screen(1,1))

However, I'm getting an illegal function call when the line with screen(1,1) is executed.

Is this only valid with screen mode 0 or am I missing something here?

If this cannot be made to work, is there any other way to read characters from the screen?

Post the actual code. The SCREEN function requires the SCREEN be properly sized as a multiple of the font height. Screw that up, and illegal function calls happen at the top of the screen.

Pete

Pete, what you say is interesting, because in the meantime I have narrowed it down to definitely somehow being related to the font.

I didn't post code initially because the relevant pieces were scattered throughout a big program, but I now have a small test program.

Let's start with this:

Code: (Select All)
FontPath$ = Environ$("SYSTEMROOT") + "\fonts\lucon.ttf"
FontSize = 20

handle& = _NewImage(800, 600, 256)
Screen handle&
_FullScreen _Off

' Font& = _LoadFont(FontPath$, FontSize, "MONOSPACE")
' _Font Font&

Locate 1, 1: Print "This is a test"

' The lines below simply display the first 4 characters located on line 1.
' In this case that would be "This".

For x = 1 To 4
    Print Chr$(Screen(1, x));
Next x

If you run the above code, it runs flawlessly. But, go ahead and uncomment the lines starting with "Font&" and "_Font". Now the program will fail. Note that I'm using a fontsize of 20 and the screen width and height are exact multiples of that.
Reply


Messages In This Thread
RE: How can I read characters from the screen? - by hanness - 05-05-2022, 10:16 PM



Users browsing this thread: 1 Guest(s)