Author Topic: 2nd Ques for today - Can I capture the char at a specific location on screen?  (Read 3648 times)

0 Members and 1 Guest are viewing this topic.

Offline hanness

  • Forum Regular
  • Posts: 210
    • View Profile
I know that I can use "Location" to move my cursor to any row and column on the screen so that I can display characters in specific locations. However, once I move to a particular location, is there any way that I can somehow retrieve the current character at that location?

Failing that, is there a way that I can simply dump the entire contents of the QB64 program screen to a text file? If so, I can then simply parse that text file to find what characters are in various spots.

FellippeHeitor

  • Guest
Code: QB64: [Select]

X and Y being the coordinates you're checking.

Marked as best answer by hanness on March 26, 2021, 10:15:02 pm

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Code: QB64: [Select]

X and Y being the coordinates you're checking.

Note:  this is only guaranteed to work in SCREEN 0.  Text screens store info in memory in 2 bytes per color&character.  All other screens only store info on a color per pixel basis, so character information has to basically be retrieved via OCR — which is quite limited in QB64.

https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Really want to be fancy use MEM functions. Or be cool and old skool using DEFSEG and PEEK!
Steve can help with the fancy stuff, I could show you the old skool way.

Or you can be boring and take the beaten path. :)
Granted after becoming radioactive I only have a half-life!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
And for graphics you can setup virtual screen array.

Modify your print command to write in both screen and virtual screen.



Offline hanness

  • Forum Regular
  • Posts: 210
    • View Profile
Thanks!

Offline hanness

  • Forum Regular
  • Posts: 210
    • View Profile
Turns out that I am using screen 0 so this works perfectly.

My program sets up a bunch of information on the screen by using locate commands to put various elements in exactly the right spots. After everything is displayed I use a simple loop to capture each character and print it to a file as you have shown me here. That file can then be printed as a really good duplicate of the screen contents.

Thanks again.