Post Reply 
Question about "User keyboard usage". Beta2 FW
11-21-2017, 10:21 PM
Post: #1
Question about "User keyboard usage". Beta2 FW
I'am using the latest Beta V2 FW but I think it is not specific to this version.

I can't find build in help about the KEY command.

In the official pdf doc I read the short text and i'd like to know if we can place more stuff inside the KEY definition and not just a
Code:
RETURN "a_function_name"
...

And I probably use this function very badly

Here are some tests...

If you try these code you will see that the KEY_minus don't work at all... on the other hand the KEY K_Ln() executes the inside stuff with success but it return a strange "_" char in the command line when I quit the terminal...

Code:
 
#pragma mode( separator(.,;) integer(h32) )

EXPORT aaa()
BEGIN
 LOCAL i;
 PRINT();
 FOR i FROM 1 TO 100 DO
   PRINT(i);
 END;
END;

KEY K_Log()
BEGIN
RETURN "aaa";
END;

KEY K_Ln()
BEGIN
LOCAL i;
 PRINT();
 FOR i FROM 1 TO 100 DO
   PRINT(i);
 END;
END;

EXPORT bbb()
BEGIN
LOCAL i,k:=0;
  FOR i FROM 1 TO 100 DO
    k:=k+i;
  END;
END;

KEY K_Plus()
BEGIN
RETURN "bbb";
END;

KEY K_Minus()
BEGIN
LOCAL i,k:=0;
  FOR i FROM 1 TO 100 DO
    k:=k+i;
  END;
END;

1) Can we do more inside a KEY redefinition than just a
Code:
RETURN "blabla_function"
?
2) Where can we find, in the calculator menu, all the redefinitions realized in various programs?
Thank you for your help.
Find all posts by this user
Quote this message in a reply
11-22-2017, 04:02 AM
Post: #2
RE: Question about "User keyboard usage". Beta2 FW
The very brief Help screen for KEY can be found both in the Program Editor's "Template / Function" menu, and in the Help Tree (under Program Catalog / Program Editor / Template Menu).

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
11-22-2017, 11:34 AM
Post: #3
RE: Question about "User keyboard usage". Beta2 FW
(11-21-2017 10:21 PM)dg1969 Wrote:  1) Can we do more inside a KEY redefinition than just a RETURN "blabla_function"?
Supposedly yes, but adding code before the RETURN can cause problems especially with integrated interfaces.
Example: PRINT, MSGBOX, INPUT, etc
It is preferable to just return strings, since that is the purpose of a redefinition.

You can return reals like:
-2+: Default value
-1: It does not do anything
0-50: Default according to key ID
51-101: Default according to key ID + Shift
102-152: Default according to key ID + ALPHA
153-203: Default according to key ID + Shift + ALPHA
204+: Default value

Example:

K_Ln return 100 → ID 49 + Shift → "_"
Code:
KEY K_Ln()
BEGIN
LOCAL i;
 PRINT();
 FOR i FROM 1 TO 100 DO
   PRINT(i);
 END;
END;

K_Minus return 5050 → Deafult value → "-"
Code:
KEY K_Minus()
BEGIN
LOCAL i,k:=0;
  FOR i FROM 1 TO 100 DO
    k:=k+i;
  END;
END;


(11-21-2017 10:21 PM)dg1969 Wrote:  2) Where can we find, in the calculator menu, all the redefinitions realized in various programs?
There is no menu that summarizes the redefinitions

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
11-22-2017, 04:42 PM (This post was last modified: 11-22-2017 04:44 PM by primer.)
Post: #4
RE: Question about "User keyboard usage". Beta2 FW
(11-22-2017 11:34 AM)Carlos295pz Wrote:  
(11-21-2017 10:21 PM)dg1969 Wrote:  1) Can we do more inside a KEY redefinition than just a RETURN "blabla_function"?
Supposedly yes, but adding code before the RETURN can cause problems especially with integrated interfaces.
Example: PRINT, MSGBOX, INPUT, etc
It is preferable to just return strings, since that is the purpose of a redefinition.
Sorry, But I don't agree.

Maybe it's not a good idea to perform INPUT or MSGBOX (in fact, I'm not sure), but it does not mean you can't do anything else.
I wrote a virtual keyboard in that way,
I'm doing much more that just "return", and it works perfectly everywhere, in program editor, notes, cas/home screen, any input form, any app...
see VBK for example.

primer
Find all posts by this user
Quote this message in a reply
11-22-2017, 06:51 PM
Post: #5
RE: Question about "User keyboard usage". Beta2 FW
(11-21-2017 10:21 PM)dg1969 Wrote:  2) Where can we find, in the calculator menu, all the redefinitions realized in various programs?
There is no menu that summarizes the redefinitions
[/quote]

Bonjour

Cela doit être réalisable avec Programs et INSTRING.


Hello

This must be achievable with Programs and INSTRING.

Sorry for my english
Find all posts by this user
Quote this message in a reply
11-22-2017, 08:42 PM (This post was last modified: 11-22-2017 08:45 PM by Tyann.)
Post: #6
RE: Question about "User keyboard usage". Beta2 FW
(11-22-2017 06:51 PM)Tyann Wrote:  
(11-21-2017 10:21 PM)dg1969 Wrote:  2) Where can we find, in the calculator menu, all the redefinitions realized in various programs?
There is no menu that summarizes the redefinitions

Bonjour

Cela doit être réalisable avec Programs et INSTRING.


Hello

This must be achievable with Programs and INSTRING.
[/quote]

Code:

CMID(s,n)
BEGIN
 IFTE(n>dim(s),"",mid(s,n));
END;
CINSTR(s,c,p)
//string,substring,position start
BEGIN
 LOCAL r;
 r:=INSTRING(CMID(s,p),c);
 IFTE(r>0,r+p−1,0);
END;

EXPORT CATK()
BEGIN
 LOCAL l,d,i,p,x,y,z,r:={};
 l:=Programs;d:=SIZE(l);
 FOR i FROM 1 TO d DO
  IF l(i)=="CATK" THEN CONTINUE; END;
  p:=Programs(i);z:=1;
  REPEAT 
   x:=CINSTR(p,"KEY K_",z);
   IF x THEN 
    y:=CINSTR(p,"END;",x)+3;
    r(0):=MID(p,x,y);
   END;
   z:=y; 
  UNTIL  NOT x; 
 END;
 EDITLIST(r,"USER",1);
END;

Un premier jet à améliorer.
CMID et CINSTR sont issus de ma STRlibrary.
Nommer le programme 'CATK'

A first throw to improve.
CMID and CINSTR are from my STRlibrary.
Name the program 'CATK'

Sorry for my english
Find all posts by this user
Quote this message in a reply
11-23-2017, 02:47 AM
Post: #7
RE: Question about "User keyboard usage". Beta2 FW
I've got one I use a lot as an example. I dont' like the hex/oct/bin/dec built-in program so I wrote my own and tied it to a user key KA_3.....Alpha 3 or the # char.

It's a menu based program called MBase(), but I activate it from the KEY function.
I don't have any code inside the KEY definition itself, but do everything inside the RETURN call as in:

RETURN STRING(EVAL(MBASE()));

I can't remember why I did it that way, but I think it was because I can allow it to return an expression string that gets evaluated by the EVAL call and then the result gets converted to a STRING, as behavior with keys can be strange when it doesn't return a string.

This seems to be a reliable way of doing it. Plus you can put whatever you want inside your function (MBase here).
Find all posts by this user
Quote this message in a reply
11-23-2017, 04:10 PM
Post: #8
RE: Question about "User keyboard usage". Beta2 FW
That is why I was added that returning -1 stops all further processing...

User keys is still very basic as you don't get information regarding where in the system you are, or other information you'd need to be able to adjust things to be more flexible. This and changing it so the processing happens first in the key evaluation tree were the only things I could slip in that wouldn't require major work.

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
11-23-2017, 08:18 PM
Post: #9
RE: Question about "User keyboard usage". Beta2 FW
Joe Horn, Carlos295pz, primer, Tyann , webmasterpdx and Tim... Thank you very much for your time.
It will take me some time to test all that ... Thanks again !
Find all posts by this user
Quote this message in a reply
11-23-2017, 10:42 PM
Post: #10
RE: Question about "User keyboard usage". Beta2 FW
(11-23-2017 04:10 PM)Tim Wessman Wrote:  That is why I was added that returning -1 stops all further processing...

Oh! with -1 PRINT it no longer overlaps the touch menu

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)