Test for text

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Heliostrapolis

Test for text

Post by Heliostrapolis »

I need to know if there is a way to test any point on the screen to see whether or not it contains text. In other words, display a text file on the screen and then pick a random point and return either true or false if that point contains text. Even if it returns what letter it contains . . . Help?
User avatar
Levi
Veteran
Posts: 79
Joined: Tue Jul 27, 2004 11:44 pm
Location: Alone and forgotten
Contact:

Wow...

Post by Levi »

pretty advaned, maybe anyway. Yeah I'm sure there is a way. More than likely it would take purposly setting text in a certain format and comparing where in the file you are to what should be appearing on the screen along with size of each character box and pixel positioning.

I don't have any direct code for this of course. SO I'm sorry I can't be of much help. However I did see something of this sort once in an HTML creator someone made for QB. They had the program call up the dir function in the shell to search for certain types of files to convert to HTML, or was it finding an HTML page for editing? Oh well, then it allowed you to click on the name and it would get the name that you clicked on and open the file. I of course have no idea where this program is. But if gives you hope and something to look for.
Later days,
Matthew

May those who love us love us
And those who don't
May the good Lord turn their hearts
And if he doesn't
May he turn their ankles
So we'll know them by their limping
-Irish prayer
Heliostrapols

Got It

Post by Heliostrapols »

Simple answer
Use the screen FUNCTION
thanx anyway
User avatar
Pete
Site Admin
Posts: 887
Joined: Sun Dec 07, 2003 9:10 pm
Location: Candor, NY
Contact:

Post by Pete »

Here's a little bit information on this...

If you'd like to check the printed character at screen position (1, 1) -- not pixel (1, 1), but row 1, column 1 of text -- you'd do this:

Code: Select all

character$ = SCREEN(1,1)
Simple as that. The SCREEN function will spit out ASCII codes, instead of a simple character of text like you'd expect. So, if you've got a "0" in position (1, 1), the PRINT SCREEN function will give you the number 48. (You first have to PRINT "0" at (1,1). If this is the first thing you print when your program begins, it will be there by default.)

It might be easier if you do this:

Code: Select all

character$ = CHR$(SCREEN(x,y))
That will return the actual ASCII character.

I don't know what happens if you check for an ASCII character at a screen position where you don't already have something PRINTed there... You might get an error, or it might just return an empty variable. Experiment and you can find out!
Post Reply