home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / pascal / 4885 < prev    next >
Encoding:
Text File  |  1992-08-17  |  1.9 KB  |  72 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!mcsun!sunic!kth.se!kjell
  3. From: kjell@elixir.e.kth.se (Kjell Rilbe)
  4. Subject: Re: have wherey - how to modify for wherex?
  5. Message-ID: <1992Aug17.152527.17246@kth.se>
  6. Sender: usenet@kth.se (Usenet)
  7. Nntp-Posting-Host: elixir.e.kth.se
  8. Organization: Dept. of EE, Royal Institute of Technology, Stockholm, Sweden
  9. References: <1992Aug17.135257.18261@javelin.sim.es.com>
  10. Date: Mon, 17 Aug 1992 15:25:27 GMT
  11. Lines: 59
  12.  
  13. In article <1992Aug17.135257.18261@javelin.sim.es.com> tpehrson@javelin.sim.es.com writes:
  14. >here's my wherey function (to find the cursor row) - how do i modify it to
  15. >find the wherex (cursor column)?
  16. >
  17. >function wherey:byte;
  18. > var reg:registers
  19. >  begin
  20. >   fillchar(reg,sizeof(reg),0);
  21. >   reg.ax:=$0300;   {change this to what?}
  22. >   intr($10,reg);
  23. >   with reg do
  24. >   wherey:=hi(Dx)+1;
  25. >  end;
  26.  
  27. I'm taking the liberty to "clean up" this procedure ;-)
  28.  
  29. FUNCTION WhereY : Byte;
  30.   VAR Reg : Registers;
  31.   BEGIN
  32.     WITH Reg DO BEGIN
  33.       AH:=$03; { BIOS function to get cursor position. }
  34.       BH:=$00; { Text page number, normally 0, but can be 0-7. }
  35.       Intr($10,Reg);
  36.       WhereY:=DH; { Same as Hi(DX), check Ctrl-F1 on Registers! }
  37.     END;
  38.   END;
  39.  
  40. FUNCTION WhereX : Byte;
  41.   VAR Reg : Registers;
  42.   BEGIN
  43.     WITH Reg DO BEGIN
  44.       AH:=$03;
  45.       BH:=$00;
  46.       Intr($10,Reg);
  47.       WhereX:=DL; { Same as Lo(DX). }
  48.     END;
  49.   END;
  50.  
  51. Simple, right?
  52.  
  53. But, why don't you use the WhereX and WhereY functions in the CRT unit?????
  54. They work just fine. The only difference is they give you coordinates
  55. X=1..80 and Y=1..25, instead of beginning with 0, but that's easy to fix:
  56.  
  57. USES CRT;
  58.  
  59. FUNCTION WhereX : Byte;
  60.   BEGIN
  61.     WhereX:=CRT.WhereX-1;
  62.   END;
  63.  
  64. ...
  65.  
  66. Or, you can just check the BIOS data area. I don't remember the addresses
  67. right now, but that info can easily be found.
  68.  
  69. /Kjell Rilbe
  70.  
  71. P.S. I know, this did get a bit lenghty......
  72.