rick@bnrunix.UUCP (Richard Johns X7191) (11/16/89)
Hi. Anyone know how to read the cursor keys from HP Pascal? I'm running HP/UX 6.5 (so far) on a 9000/300. TIA. Rick Johns BNR Research Triangle Park, NC (919)991-7191 rti!bnrunix!rick@mcnc.org uunet!mcnc.org!bnrunix!rick@uunet.UU.NET rjohns@bnr.ca ================================================================================ The word is "its". "It's" is something else entirely. ================================================================================
bigelow@hpfcso.HP.COM (Jim Bigelow) (11/17/89)
rick@bnrunix.UUCP (Richard Johns X7191) writes: > Hi. Anyone know how to read the cursor keys from HP Pascal? I'm running > HP/UX 6.5 (so far) on a 9000/300. TIA. This appears to be a matter of interfacing with the unix curses library. In a pascal module, define the curses routines as external and alias them the _<name> format that ld will see. Then include the curses library on the compile line and let the linker load the routines. Read up on the alias and underscore compiler directives. For example, in /usr/include/curses.h is the definition of wgetch which gets a character through a given window: int wgetch(); /* because it can return KEY_*, for instance. */ The linker will look wgetch as "_wgetch", so the pascal defintion is something like: function wgetch['_wgetch'] (var current_window): integer; external; or function $alias '_wgetch'$ wgetch(var win):integer; external; Note: 1) Refer to the Section "Pascal and Other Languages" in the 6.5 pascal manual. 2) Pascal is not a case sensitive language, so alias are converted to lower case, which makes it hard to link to LINES and COLS in the curses library, the 8.0 Release will have a new compiler directive, literal_alias to preserve the case of aliases. Until then, you have to write interface routines in C and use them to access the mixed-case variables and routines. 3) If you use curses, you'll have to translate the structures and definitions in /usr/include/curses.h into a pascal equivilent. I notices that there are lots of macros as functions in there, watch out! Here is a tentative translation of the window struct. type short : 0..65535 {2 bytes} shortptr : ^short; bool : 0..255 {1 byte} chtype : integer; {4 bytes} chtyptr : ^chtype; { * int} chtypptr : ^chtyptr; { ** int} curses_win = packer record _cury, _curx : short; _maxy, _maxx : short; _begy, _begx : short; _flags : short; _attrs : chtype; _clear : bool; _leave : bool; _scroll : bool; _use_idl : bool; _use_keypad: bool; /* 0=no, 1=yes, 2=yes/timeout */ _use_meta: bool; /* T=use the meta key */ _nodelay: bool; /* T=don't wait for tty input */ _y: chtypptr; _firstch: shortptr; _lastch: shortptr; _tmarg,_bmarg short; end; Good Luck, Jim Bigelow S300 Pascal Colorado Language Lab Hewlett Packard Standard disclaimer Nothing I say is legally binding on HP, or myself and represents my opinion and not that of my employer.