dbTalk Databases Forums  

_efrgetkey

comp.databases.informix comp.databases.informix


Discuss _efrgetkey in the comp.databases.informix forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Malc
 
Posts: n/a

Default _efrgetkey - 12-08-2011 , 04:37 AM






Hi all
Having a ball here doing proof-of-concept converting our old HP-UX 4GL
to see if we can run it on Ubuntu using A.N. Other vendor's 4GL
compiler ...

The final thing I need to do to get code running properly...
Currently (on HP-UX/Informix i4gl) we link some C into all our 4ge's
to do various things and most of it has come across OK now *BUT* we
have a vital C function that calls internal 4GL function "_efrgetkey";
this returns the integer value of a single keystroke (without the need
for a CR) and we use it for navigating around screen text and other
stuff in many programs. As well as all the standard keys we also need
it to recognise the UP,DOWN,LEFT,RIGHT arrows, all the F keys, ALT-key
combinations and so on...

_efrgetkey is defined in ${INFORMIXDIR}/incl/tools/lib4io.a, where we
have SHLIB_PATH pointed at. Trouble is, without the Informix 4gl
tools, we don't obviously have access to this function (although nm of
$INFORMIXDIR/bin shows it as defined in 'onmonitor' which is
interesting)...

The c code is basically as follows:
/* Specify the Informix getkey function */
short _efrgetkey ();

/* Get a single keystroke and return the integer value */
get_a_key(n)
retint(_efrgetkey()) ;
return 1 ;
}

fgl_getkey() won't do because it requires a <CR>.
fgl_lastkey() doesn't work properly outside a form environment.
PROMPT "" FOR CHAR lv_key doesn't recognise the arrows and alt keys
and so on.
Opening a 1X1 form and doing fgl_lastkey would be pretty ugly...

Is there any other way anyone can think of?
Ta

Reply With Quote
  #2  
Old   
Art Kagel
 
Posts: n/a

Default Re: _efrgetkey - 12-08-2011 , 04:53 AM






Just steal the keystroke away from 4GL:

int getkey( int n )
{
int ret;
....
read( 0, &ret, 1 );
retint( ret );
}

Art

Art S. Kagel
Advanced DataTools (www.advancedatatools.com)
Blog: http://informix-myview.blogspot.com/

Disclaimer: Please keep in mind that my own opinions are my own opinions
and do not reflect on my employer, Advanced DataTools, the IIUG, nor any
other organization with which I am associated either explicitly,
implicitly, or by inference. Neither do those opinions reflect those of
other individuals affiliated with any entity with which I am affiliated nor
those of the entities themselves.



On Thu, Dec 8, 2011 at 5:37 AM, Malc <malcrp (AT) googlemail (DOT) com> wrote:

Quote:
Hi all
Having a ball here doing proof-of-concept converting our old HP-UX 4GL
to see if we can run it on Ubuntu using A.N. Other vendor's 4GL
compiler ...

The final thing I need to do to get code running properly...
Currently (on HP-UX/Informix i4gl) we link some C into all our 4ge's
to do various things and most of it has come across OK now *BUT* we
have a vital C function that calls internal 4GL function "_efrgetkey";
this returns the integer value of a single keystroke (without the need
for a CR) and we use it for navigating around screen text and other
stuff in many programs. As well as all the standard keys we also need
it to recognise the UP,DOWN,LEFT,RIGHT arrows, all the F keys, ALT-key
combinations and so on...

_efrgetkey is defined in ${INFORMIXDIR}/incl/tools/lib4io.a, where we
have SHLIB_PATH pointed at. Trouble is, without the Informix 4gl
tools, we don't obviously have access to this function (although nm of
$INFORMIXDIR/bin shows it as defined in 'onmonitor' which is
interesting)...

The c code is basically as follows:
/* Specify the Informix getkey function */
short _efrgetkey ();

/* Get a single keystroke and return the integer value */
get_a_key(n)
retint(_efrgetkey()) ;
return 1 ;
}

fgl_getkey() won't do because it requires a <CR>.
fgl_lastkey() doesn't work properly outside a form environment.
PROMPT "" FOR CHAR lv_key doesn't recognise the arrows and alt keys
and so on.
Opening a 1X1 form and doing fgl_lastkey would be pretty ugly...

Is there any other way anyone can think of?
Ta
_______________________________________________
Informix-list mailing list
Informix-list (AT) iiug (DOT) org
http://www.iiug.org/mailman/listinfo/informix-list

Reply With Quote
  #3  
Old   
Malc P
 
Posts: n/a

Default Re: _efrgetkey - 12-08-2011 , 05:48 AM



Hmm weird - having compiled that in and trying it, each time I restart a program the value returned is different...

e.g.

call getkey() returning lv_keyval

....and hitting "1" returns 7389745 one time, 12071474 the next, 1417777 thenext and so on (but while the program is running, calling it repeatedly ina loop returns the same value every time). Is this some kind of initialization issue? I need to be able to use the returned integer value to determine the keystroke name.

Reply With Quote
  #4  
Old   
Malc P
 
Posts: n/a

Default Re: _efrgetkey - 12-08-2011 , 05:56 AM



Oh hang on - I checked the hex values for the returns, and they all have the same last 16 bits so I redefined "ret" as a "short int" and we're getting somewhere now!

Reply With Quote
  #5  
Old   
Art Kagel
 
Posts: n/a

Default Re: _efrgetkey - 12-08-2011 , 09:20 AM



Oh yeah, endianness issue! I last did that level of coding on Sparc
processors, so I forgot.
Art S. Kagel
Advanced DataTools (www.advancedatatools.com)
Blog: http://informix-myview.blogspot.com/

Disclaimer: Please keep in mind that my own opinions are my own opinions
and do not reflect on my employer, Advanced DataTools, the IIUG, nor any
other organization with which I am associated either explicitly,
implicitly, or by inference. Neither do those opinions reflect those of
other individuals affiliated with any entity with which I am affiliated nor
those of the entities themselves.



On Thu, Dec 8, 2011 at 6:56 AM, Malc P <malcrp (AT) googlemail (DOT) com> wrote:

Quote:
Oh hang on - I checked the hex values for the returns, and they all have
the same last 16 bits so I redefined "ret" as a "short int" and we're
getting somewhere now!
_______________________________________________
Informix-list mailing list
Informix-list (AT) iiug (DOT) org
http://www.iiug.org/mailman/listinfo/informix-list

Reply With Quote
  #6  
Old   
Art Kagel
 
Posts: n/a

Default Re: _efrgetkey - 12-08-2011 , 09:26 AM



Oh, make that data type for ret be char - that would be best. Also add a
check on the return code from read(). It returns the number of bytes read
so when the return value is zero, you can return an empty string or a
NULL/0 int instead of just returning the existing contents of ret which in
a tight loop will be the previous contents from the last call (but don't
depend on that unless you change the declaration of ret to be static) until
the stack is changed by some other function call - then it will be garbage.

Art

Art S. Kagel
Advanced DataTools (www.advancedatatools.com)
Blog: http://informix-myview.blogspot.com/

Disclaimer: Please keep in mind that my own opinions are my own opinions
and do not reflect on my employer, Advanced DataTools, the IIUG, nor any
other organization with which I am associated either explicitly,
implicitly, or by inference. Neither do those opinions reflect those of
other individuals affiliated with any entity with which I am affiliated nor
those of the entities themselves.



On Thu, Dec 8, 2011 at 6:48 AM, Malc P <malcrp (AT) googlemail (DOT) com> wrote:

Quote:
Hmm weird - having compiled that in and trying it, each time I restart a
program the value returned is different...

e.g.

call getkey() returning lv_keyval

...and hitting "1" returns 7389745 one time, 12071474 the next, 1417777
the next and so on (but while the program is running, calling it repeatedly
in a loop returns the same value every time). Is this some kind of
initialization issue? I need to be able to use the returned integer value
to determine the keystroke name.
_______________________________________________
Informix-list mailing list
Informix-list (AT) iiug (DOT) org
http://www.iiug.org/mailman/listinfo/informix-list

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.