× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: How to Trap the cursor position ?????
  • From: dhandy@xxxxxxxxxxx (Douglas Handy)
  • Date: Mon, 06 Mar 2000 11:12:42 -0500

Jaydeep,

>Is there any way  to trap cursor position (giving X ,Y  coordinates) ,when user
>presses arrow keys.

Not directly.  Unlike a PC, keystrokes do not generate an interrupt of
the main CPU(s).  Instead devices operate in a block mode with all
keystrokes handled by the workstation controller (or its equivalent)
until one of the so-called AID keys is pressed.  AID stands for
something Attention IDentification, and basically consists of the
Enter key, Fx keys, Page Up/Down, SysReq/Attn, and a couple of misc
other ones like Print, Help, Clear and Home (when cursor is already
home).

The presumption is that other keys do not need the attention of the
CPU and can be handled directly by the WS controller.  For most line
of business apps, this works out very well and increases the overall
efficiency of how things work, especially task dispatching.

It does not work very well for some other scenarios, like games.

It is possible to request the current cursor position from the WS
controller without the need to wait for an AID key.  But this would
need to be done in a loop (or whatever) in your program where you
compared the current position to a previous iteration, and not as an
event triggered by a key being pressed.

This has obvious negative performance implications.  You could kill
your system while still not really knowing every keystroke.

If you have a dedicated system and want to play with this, the easiest
way to get the current cursor address is with one of the Dynamic
Screen Manager API's.  Here is the prototype I use:

      * Get cursor address (does not wait for AID key).
     D GetCsrAdr       PR            10I 0 ExtProc( 'QsnGetCsrAdr' )
     D  CsrRow                       10I 0 Options( *Omit )
     D  CsrCol                       10I 0 Options( *Omit )
     D  EnvHnd                       10I 0 Options( *Omit ) Const
     D  ErrorDS                            Options( *Omit ) Like(
ApiErrDS )

where ApiErrDS is my standard DS used for most API's.

You could call it like this:

     D  Row                          10I 0
     D  Col                          10I 0
     C                   Callp     GetCsrAdr( Row: Col: *Omit: *Omit )

and ignore the return value (a completion code) and the last two API
arguments.  Note that this API requires the Row/Col variables to be
4-byte binary fields.

Please don't try this in a tight loop on a production machine running
at the same priority as other interactive jobs.  :(

I have the API prototyped because there are rare cases where I utilize
it, but trying to trap cursor movement isn't one of them.

Doug
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.