In search for a function !

Hi, i was wondering if anyone can tell me if there is a function/procedure in pascal that lets me know what character i have at some coordinates on the screen, for example, if i write this on the screen:

[italic]asfaga
as7sga
wteery[/italic]

and lets say i would like to know what character i have at coords 3,2 it would return me the character [italic]7[/italic]
PS:the characters that i have on the screen are not from a matrix or anything like that.

Thank you!

Comments

  • In pascal it isn't any procedure or function that can tell you what you want .... but you can create one yourself

    try the following ... (i would do this way)
    when writing on the scrren something contemporanly write it on a text file
    EX.

    Writeln('I am Albi'); // this is for the screen
    writeln(yourfile,'I am Albi'); //this is for yout temporanly file....

    then when you need to know the character of coordinates read the file and pass all strings of it in a vector like s:array[1..100000000]of string; {for 100000000 lines} and then ... Ex coordinates(5,3)
    you should find s[3][5] and it is the wanted char .... I hope i was helpful to you
  • well to explain better, all that i have on my screen i read from a text file into a matrix and then write that matrix, so i am using that method you told me at this moment, wanted to see if i could do it the other way tho but i stick to this one...really appreciating for reply, 10x
  • The metod that i told you was an idea that came to me momentanly when i red your post but you confirmed e that it could function ...for the moment i havent any other idea but if you explain me about the program maybe i can help you more . For Ex explain me for what is the program about and from where should it take the inputs and maybe i can help you .

    Ps.
    If your program get the inputs by the keyboard you haven't to put them all in the text file but you can add them directly to a vector in the moment that you write them to the screen ('or a matrix cuz the string is also a vector of chars and should be the same a vector with a matrix in this case ') and then you know the way to give the char of cordinates (x,y). If you didn' understand me very well, please read this text more times and don't hesitate to ask me for an example of the program or for the entire program
  • this program is actually a game, (made at the moment out of ASCII characters, i didn't learned yet anything about Graph mode) you can move around a character on the screen and avoid obstacles (so far), the obstacles (the stage) i read them from a text file into a matrix and write that matrix, and i had a little problem when i was moving my controllable object, ill give an example if, lets say, i would like to move my object up, it should work like this:
    1)i press up (the 'w' key)
    2)go check if the object can move there
    3)if it can then: a) delete the object from previous position
    b) write it at the next position
    4)if there is an obstacle then don't move the object to that position
    and my problem was with step 2, it wasn't working as it should so i thought there would be a function i could use to do that in another way, but don't worry i solved the problem, almost.

  • Are you using Windows or Dos?

    If DOS, you can access the screen directly:

    [code]
    FUNCTION GetChar(X, Y : Word) : Char;
    CONST
    TextScreen = $B800;
    Begin
    GetChar := Chr(Mem[TextScreen: Y*160 + X*2]);
    { GetChar := Chr(Mem[TextScreen: Y*160 + X*2+1]); }
    End;
    [/code]

    It's been a while, but I think it's the first line and the second is for the color of the character on the screen. If You keep getting the same value, try the second line instead.

    *EXTRA INFO* Each character on the screen is defined as two bytes. One is the actual character, then second is the color. The top four bits is the background color, the lower four bits it the forecolor, so $1F would be bgColor(1) and forColor(15), so White text on a Blue background.
  • I assume you work on a PC platform.
    What if you write to some matrix you define (with screen size) and then you transfer this matrix to screen memory?
    This way you will have a copy of what is on screen in your variable.
    Or you could probably read directly from screen memory - you will need a function to calculate screen memory address and to return your character.
    [link=http://turbo51.com/download-free-pascal-compiler-8051]Download Turbo51[/link] - my favorite 8051 compiler
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories