Post Reply 
Entering the 'Edit Integer' window
12-19-2023, 08:12 PM
Post: #1
Entering the 'Edit Integer' window
A little thing that niggles me a lot is when trying to enter the 'Edit Integer' window to convert hex to dec etc, which I often do, I press Shift then press '-'. Most of the time upon first press the calculator will output a # to the home screen.

What causes this, and how can I stop it? Is it possible for me to set up my own shortcut to call the 'Edit Integer' window?
Find all posts by this user
Quote this message in a reply
12-19-2023, 08:52 PM
Post: #2
RE: Entering the 'Edit Integer' window
Isn't that just letting you enter a hex value?
Find all posts by this user
Quote this message in a reply
12-19-2023, 08:57 PM (This post was last modified: 12-19-2023 09:06 PM by matalog.)
Post: #3
RE: Entering the 'Edit Integer' window
(12-19-2023 08:52 PM)KeithB Wrote:  Isn't that just letting you enter a hex value?

Well, ALPHA + '3' is designed to Enter a '#'. I don't know why SHIFT + '-' is doing it.

Is it a bug or does it have a use?
Find all posts by this user
Quote this message in a reply
12-19-2023, 10:21 PM
Post: #4
RE: Entering the 'Edit Integer' window
It signals that you are about to do integer arithmetic:
"You indicate that you are about to engage in integer arithmetic by preceding the number with the pound symbol (#,"

The intent of the integer screen is to let you enter a number in any base.
Find all posts by this user
Quote this message in a reply
12-19-2023, 11:02 PM
Post: #5
RE: Entering the 'Edit Integer' window
(12-19-2023 10:21 PM)KeithB Wrote:  It signals that you are about to do integer arithmetic:
"You indicate that you are about to engage in integer arithmetic by preceding the number with the pound symbol (#,"

The intent of the integer screen is to let you enter a number in any base.

Sorry, I don't seem to be understanding you.

I know what the pound symbol is for, but it is supposed to be called by the Alpha key plus the '3' key. Not by the Shift key plus the '-' key.
Find all posts by this user
Quote this message in a reply
12-20-2023, 12:26 AM (This post was last modified: 12-20-2023 12:32 AM by Dougggg.)
Post: #6
RE: Entering the 'Edit Integer' window
You can use either one it is the same character, it may have been oversight bu eitherbone will work

Actually may be a bug, in home the base I get a #, in cas it pulls up a edit integer screen, probably in home should pull up the edit integer as well, I think it use to
Find all posts by this user
Quote this message in a reply
12-20-2023, 12:56 AM
Post: #7
RE: Entering the 'Edit Integer' window
(12-20-2023 12:26 AM)Dougggg Wrote:  Actually may be a bug, in home the base I get a #, in cas it pulls up a edit integer screen, probably in home should pull up the edit integer as well, I think it use to

In Home, if item 1 on the history stack is an integer, then SHIFT+Base brings up the Edit Integer screen. Otherwise it puts # into the input line.

This behaviour is too deliberate to be a mistake so make of it what you will. I suspect they thought of a better way for SHIFT+Base to work only after the keyboard layout was finalised and it was too late to change the character that ALPHA-3 produced.
Find all posts by this user
Quote this message in a reply
12-21-2023, 09:20 AM
Post: #8
RE: Entering the 'Edit Integer' window
So is there a way to definitely get into the Edit Integer window with one or 2 key presses?

Is there any way to call the window from a program? In which case, I could write a program to get me there in one keypress.
Find all posts by this user
Quote this message in a reply
12-21-2023, 02:20 PM
Post: #9
RE: Entering the 'Edit Integer' window
I don't see a "BASE" or "EDITBASE" command in the toolbox catalog.
Find all posts by this user
Quote this message in a reply
12-26-2023, 07:24 PM
Post: #10
RE: Entering the 'Edit Integer' window
(12-19-2023 11:02 PM)matalog Wrote:  
(12-19-2023 10:21 PM)KeithB Wrote:  It signals that you are about to do integer arithmetic:
"You indicate that you are about to engage in integer arithmetic by preceding the number with the pound symbol (#,"

The intent of the integer screen is to let you enter a number in any base.

Sorry, I don't seem to be understanding you.

I know what the pound symbol is for, but it is supposed to be called by the Alpha key plus the '3' key. Not by the Shift key plus the '-' key.

Hi Matalog

First entering in hex, octal, decimal or binary like: ALPHA-3, Value, Format; '#11001b', Enter.
When in the first stack, '2nd', 'Base' and it opens the integer arithmetic with the Input from stack.

Regards, Tschumi
Find all posts by this user
Quote this message in a reply
12-26-2023, 09:38 PM (This post was last modified: 12-26-2023 10:21 PM by komame.)
Post: #11
RE: Entering the 'Edit Integer' window
In general, to enter the "Edit Integer" window with the first press of Shift [-], there are two approaches. The first approach involves having an integer value on the history stack (marked with a "#" sign at the beginning) as someone already mentioned in this thread. As for the second approach, the only condition is to be in edit mode (blinking cursor). There doesn't need to be any value on the stack or even in the editing field where the cursor is; you just need to enter the edit mode of anything. For instance, you can go to HOME and press the space, multiplication, or any other key that outputs any character on the screen (then the cursor will appear - edit mode), then press Shift [-] and the "Edit Integer" window will open immediately. Another good example is the PPL editor, which is always in edit mode and pressing Shift [-] always immediately opens "Edit Integer".
If you're not in edit mode, the first press produces "#" and simultaneously switches to edit mode, so the second press opens the "Edit Integer" window and the "#" character here has no impact on the fact of opening this window.
I am convinced that the appearance of the "#" sign after pressing Shift [-] is not only problematic, but it is definitively a bug. This is because if there’s no value on the stack and the first press of Shift [-] causes "#" to appear, and the second press opens the "Edit Integer" window, then after finishing editing the value by clicking "OK" (or pressing Enter), the "#" sign is automatically added, which results in a double "#" sign, such as ##64, in the command line in HOME, which is an incorrect value.
I see no justification for such behavior.

(12-20-2023 12:26 AM)Dougggg Wrote:  Actually may be a bug, in home the base I get a #, in cas it pulls up a edit integer screen, probably in home should pull up the edit integer as well, I think it use to
Nope, in CAS it behaves exactly the same way as in HOME.
On the other hand, using this in CAS probably doesn't make sense, because the result of the editing from this window will be interpreted in CAS as a character string, not as a number.

Piotr Kowalewski
Find all posts by this user
Quote this message in a reply
12-27-2023, 06:54 AM
Post: #12
RE: Entering the 'Edit Integer' window
(12-21-2023 09:20 AM)matalog Wrote:  So is there a way to definitely get into the Edit Integer window with one or 2 key presses?

Is there any way to call the window from a program? In which case, I could write a program to get me there in one keypress.

I don't know, but 'GETBASE()' can be the solution with a Prog..
When SETBASE is predefined to decimal (Settings -> Integer)you also can go the way with '#25', '2nd', 'Base'.


Regards


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
01-04-2024, 06:16 PM (This post was last modified: 01-04-2024 06:18 PM by komame.)
Post: #13
RE: Entering the 'Edit Integer' window
(12-21-2023 09:20 AM)matalog Wrote:  So is there a way to definitely get into the Edit Integer window with one or 2 key presses?

Is there any way to call the window from a program? In which case, I could write a program to get me there in one keypress.

Hi Matalog,

If you use the "Customizing key presses" described in the manual (third edition) on page 615, you can enable persistent user mode (by pressing the "User" combination twice (Shift+Help, Shift+Help)) and then, by applying the appropriate program, you can simulate the "Edit Integer" window.
I am attaching a very simple example that demonstrates this capability. It also works in other programs, even in the PPL editor.
   

But it's just a proof of concept; it converts only from DEC to HEX and only small numbers. Only the keys from 0 to 9, backspace and Enter work; there's no error handling, no optimization, etc. However, you can adapt it to your needs and then you'll probably achieve what you're looking for.

The header "KEY KS_Minus()" means that the program is assigned to the "Base" function, replacing the original "Edit Integer" mechanism as long as you have the user mode enabled.

Best wishes,
Piotr


Attached File(s)
.zip  EDIT_INTEGER.zip (Size: 992 bytes / Downloads: 3)
Find all posts by this user
Quote this message in a reply
01-07-2024, 11:23 PM
Post: #14
RE: Entering the 'Edit Integer' window
Yes, good idea, it's great for quick conversion of dec to hex.

Thanks.
Find all posts by this user
Quote this message in a reply
01-08-2024, 12:33 AM (This post was last modified: 01-08-2024 12:50 AM by matalog.)
Post: #15
RE: Entering the 'Edit Integer' window
Here is the program adapted to convert Hex to Dec or Dec to Hex, you can switch with the 'Apps' button.

Code:
KEY KS_Minus()
BEGIN
  local hc="0123456789ABCDEF";
  local w, s, d, key, keys=MAKELIST(-1,X,0,50), value;
  keys:=REPLACE(keys,32,{7,8,9,-1,-1,4,5,6,-1,-1,1,2,3,-1,-1,0});
  keys:=REPLACE(keys,14,{10,11,12,13,14,-1,15});
  keys[0]:=20;   //
  keys[19]:=99;  //backspace
  keys[30]:=100; //enter
  local s,h,i,he,curkey;
 he:=0;
  RECT_P(80,80,240,146,0,16777215);
  BLIT_P(80,61,241,81,G0,0,0,1,20);
  TEXTOUT_P("Edit Integer",123,62,3,16777215);
  TEXTOUT_P("ENTER => OK",88,130,1);
  REPEAT
 IF he=0 THEN
    w:=IFTE(value=0,88,TEXTOUT_P(STRING(value,1),88,86,2,0,144,16777215));
    s:=CONVERT(value,"base",16);
    d:=GET(SIZE(s),1);
    h:="";
    FOR i FROM 1 TO d DO

      h:=h+CHAR(hc[s[i]+1]);

    END;

    RECT_P(w,81,239,97);
    RECT_P(w,86,w+9,97,0);
    w:=TEXTOUT_P("HEX: "+h,88,100,2,0,144,16777215);
    RECT_P(w,100,239,111);
    key:=keys[WAIT(0)];
    IF key=100 THEN
      RETURN "#"+h+"h";
    END;
    IF key=99 or key <> -1 AND key <10 THEN
      value:=IFTE(key=99,IP(value/10),value*10+key);
    END;
    IF key=20 THEN
    RECT_P(86,86,239,111);
    he:=1;
    //value:=0;
    END;
    IF key=21 THEN   // Symb Key sets value to 0
    value:=0;
    END;
 END;
 IF he=1 THEN
    w:=TEXTOUT_P(STRING(value,1),88,86,2,0,144,16777215);
    s:=CONVERT(value,"base",16);
    d:=GET(SIZE(s),1);
    h:="";
    FOR i FROM 1 TO d DO
    IF value>0 THEN
      h:=h+CHAR(hc[s[i]+1]);
    END;
    END;
    RECT_P(w,86,239,97);
    w:=TEXTOUT_P("HEX: "+h,88,100,2,0,144,16777215);


    RECT_P(w,100,239,111);
    RECT_P(w,100,w+9,111,0);
    key:=keys[WAIT(0)];
    IF key=100 THEN
      RETURN "#"+h+"h";
    END;
    IF key=99 or key <> -1 and key<19 THEN
      value:=IFTE(key=99,IP(value/16),value*16+key);
    END;
    IF key=20 THEN
    he:=0;
    END;
    IF key=21 THEN   // Symb Key sets value to 0
    value:=0;
    END;
 END;
  UNTIL ISKEYDOWN(4);  //ESC will exit
RETURN 46;  //one way to exit program with no apparent consequences
END;
Find all posts by this user
Quote this message in a reply
01-08-2024, 01:12 AM (This post was last modified: 01-08-2024 09:27 AM by matalog.)
Post: #16
RE: Entering the 'Edit Integer' window
And a little bit shorter: (edited)

Code:
KEY KS_Minus()
BEGIN
  local hc="0123456789ABCDEF";
  local w, s, d, key, keys=MAKELIST(-1,X,0,50), value;
  keys:=REPLACE(keys,32,{7,8,9,-1,-1,4,5,6,-1,-1,1,2,3,-1,-1,0});
  keys:=REPLACE(keys,14,{10,11,12,13,14,-1,15});
  keys[0]:=20;   //
  keys[1]:=21;
  keys[19]:=99;  //backspace
  keys[30]:=100; //enter
  local s,h,i,he;
 he:=0;
  RECT_P(80,80,240,146,0,16777215);
  BLIT_P(80,61,241,81,G0,0,0,1,20);
  TEXTOUT_P("Edit Integer",123,62,3,16777215);
  TEXTOUT_P("ENTER => OK",88,130,1);
  REPEAT

    w:=IFTE(he=0,IFTE(value=0,88,TEXTOUT_P(STRING(value,1),88,86,2,0,144,167772​15)),TEXTOUT_P(STRING(value,1),88,86,2,0,144,16777215));
    s:=CONVERT(value,"base",16);
    d:=GET(SIZE(s),1);
    h:="";
    FOR i FROM 1 TO d DO
    IF he and value>0 THEN
      h:=h+CHAR(hc[s[i]+1]);
    END;
    IF he=0 THEN
      h:=h+CHAR(hc[s[i]+1]);
    END;
    END;
    RECT_P(w,81,239,97);
    IF he=0 THEN 
    RECT_P(w,86,w+9,97,0);
    END;
    w:=TEXTOUT_P("HEX: "+h,88,100,2,0,144,16777215);
    RECT_P(w,100,239,111);
    IF he=1 THEN
        RECT_P(w,100,w+9,111,0);
    END;
    key:=keys[WAIT(0)];
    IF key=100 THEN
      RETURN "#"+h+"h";
    END;
    IF key=99 or key <> -1 AND key <10+he*9 THEN
      value:=IFTE(key=99,IP(value/(10+6*he)),value*(10+6*he)+key);
    END;
    IF key=20 THEN
    RECT_P(86,86,239,111);
    he:=NOT he;
    END;
    IF key=21 THEN   // Symb Key sets value to 0
    value:=0;
    END;

  UNTIL ISKEYDOWN(4);  //ESC will exit
RETURN 46;  //one way to exit program with no apparent consequences
END;
Find all posts by this user
Quote this message in a reply
01-08-2024, 11:59 AM
Post: #17
RE: Entering the 'Edit Integer' window
And stopping the program run beyond it's limits.

It can handle numbers up to #FFFFFFFFF or 999999999999.

Apps switches between hex and dec input and symb resets to zero.

Code:
KEY KS_Minus()
BEGIN
  local hc="0123456789ABCDEF";
  local w, s, d, key, keys=MAKELIST(-1,X,0,50), value;
  keys:=REPLACE(keys,32,{7,8,9,-1,-1,4,5,6,-1,-1,1,2,3,-1,-1,0});
  keys:=REPLACE(keys,14,{10,11,12,13,14,-1,15});
  keys[0]:=20;   //
  keys[1]:=21;
  keys[19]:=99;  //backspace
  keys[30]:=100; //enter
  local s,h,i,he,ov;
 he:=0;
  RECT_P(80,80,240,146,0,16777215);
  BLIT_P(80,61,241,81,G0,0,0,1,20);
  TEXTOUT_P("Edit Integer",123,62,3,16777215);
  TEXTOUT_P("ENTER => OK",88,130,1);
  REPEAT

    w:=IFTE(he=0,IFTE(value=0,88,TEXTOUT_P(STRING(value,1),88,86,2,0,144,167772​15)),TEXTOUT_P(STRING(value,1),88,86,2,0,144,16777215));
    s:=CONVERT(value,"base",16);
    d:=GET(SIZE(s),1);
    h:="";
    FOR i FROM 1 TO d DO
    IF he=0  or he and value>0 THEN
      h:=h+CHAR(hc[s[i]+1]);
 //  RECT_P(80,200,240,220,16777215,16777215);
  // TEXTOUT_P(h,80,200,1);
    END;

    END;
    RECT_P(w,81,239,97);
    IF he=0 THEN 
    RECT_P(w,86,w+9,97,0);
    END;
    w:=TEXTOUT_P("HEX: "+h,88,100,2,0,144,16777215);
    RECT_P(w,100,239,111);
    IF he=1 THEN
        RECT_P(w,100,w+9,111,0);
    END;
    key:=keys[WAIT(0)];
    IF key=100 THEN
      RETURN "#"+h+"h";
    END;
    IF key=99 or key <> -1 AND key <10+he*9 THEN
      ov:=value;
      value:=IFTE(key=99,IP(value/(10+6*he)),value*(10+6*he)+key);

    
      IF value>999999999999 THEN
    value:=ov;
    END;
    END;
    IF key=20 THEN
    RECT_P(86,86,239,111);
    he:=NOT he;
    END;
    IF key=21 THEN   // Symb Key sets value to 0
    value:=0;
    END;

  UNTIL ISKEYDOWN(4);  //ESC will exit
RETURN 46;  //one way to exit program with no apparent consequences
END;
Find all posts by this user
Quote this message in a reply
01-08-2024, 07:35 PM (This post was last modified: 01-08-2024 07:43 PM by komame.)
Post: #18
RE: Entering the 'Edit Integer' window
I've added some optimizations.

Code:
KEY KS_Minus()
BEGIN
  local hc="0123456789ABCDEF", white=16777215;
  local wd, wh, key, keys=MAKELIST(-1,X,0,50), value;
  keys:=REPLACE(keys,32,{7,8,9,-1,-1,4,5,6,-1,-1,1,2,3,-1,-1,0});
  keys:=REPLACE(keys,14,{10,11,12,13,14,99,15});
  keys[0]:=20;
  keys[1]:=21;
  keys[30]:=100;
  local s,h,i,he=0,ov;

  RECT_P(80,80,240,146,0,white);
  BLIT_P(80,61,241,81,G0,0,0,1,20);
  TEXTOUT_P("Edit Integer",123,62,3,white);
  TEXTOUT_P("DEC:",88,86,2,0); TEXTOUT_P("HEX:",88,100,2,0);
  TEXTOUT_P("APPS => base, ENTER => OK",88,130,1);

  REPEAT
    wd:=TEXTOUT_P(STRING(value,1),115,86,2,0,144,white);
    h:=CHAR(EXECON("hc[&1+1]",CONVERT(value,"base",16)));

    RECT_P(wd,81,239,97); // clear the space after DEC
    wh:=TEXTOUT_P(h,115,100,2,0,144,white);
    RECT_P(wh,100,239,111); // clear the space after HEX

    IF value = 0 THEN
      115▶wd▶wh;
    END;
    IF he THEN
      RECT_P(wh,100,wh+6,111,0);
    ELSE
      RECT_P(wd,86,wd+6,97,0);
    END;
    key:=keys[WAIT(0)];
    CASE
      IF key=100 THEN
        RETURN "#"+h+"h";
      END;
      IF key >= 0 AND key < 10+he*9 or key=99 THEN
        ov:=value;
        value:=IFTE(key=99,IP(value/(10+6*he)),value*(10+6*he)+key);
        IF value>999999999999 THEN
          value:=ov;
        END;
      END;
      IF key=20 THEN // Apps changes the base
        he:=NOT he; //RECT_P(115,86,239,111); // unnecessary
      END;
      IF key=21 THEN   // Symb Key sets value to 0
        value:=0;
      END;
    END;
  UNTIL ISKEYDOWN(4);  //ESC will exit

  RETURN 46;  //one way to exit program with no apparent consequences
END;

I think we're not far from a solution where this could be turned into a real editor, with the ability to move the cursor across the digits (left and right) and edit them at specific positions.
I'm leaving for the whole day tomorrow, but if you don't get this sorted out by then, I'll take care of it the day after tomorrow Wink
Find all posts by this user
Quote this message in a reply
01-08-2024, 10:49 PM
Post: #19
RE: Entering the 'Edit Integer' window
Something in the line

h:=CHAR(EXECON("hc[&1+1]",CONVERT(value,"base",16)));

Seems to be crashing the program as soon as it is run on my calcualtor.
Find all posts by this user
Quote this message in a reply
01-08-2024, 11:14 PM
Post: #20
RE: Entering the 'Edit Integer' window
This is the same version reverted to the old way for h:= and working again, mainly so I have access to look at it in work tomorrow if I get time.

Code:
EXPORT intedit()
BEGIN
  local hc="0123456789ABCDEF", white=16777215;
  local wd, wh, key, keys=MAKELIST(-1,X,0,50), value;
  keys:=REPLACE(keys,32,{7,8,9,-1,-1,4,5,6,-1,-1,1,2,3,-1,-1,0});
  keys:=REPLACE(keys,14,{10,11,12,13,14,99,15});
  keys[0]:=20;
  keys[1]:=21;
  keys[30]:=100;
  local s,d,h="",i,he=0,ov;

  RECT_P(80,80,240,146,0,white);
  BLIT_P(80,61,241,81,G0,0,0,1,20);
  TEXTOUT_P("Edit Integer",123,62,3,white);
  TEXTOUT_P("DEC:",88,86,2,0); TEXTOUT_P("HEX:",88,100,2,0);
  TEXTOUT_P("APPS => base, ENTER => OK",88,130,1);

  REPEAT
    h:="";
    s:=CONVERT(value,"base",16);
    d:=GET(SIZE(s),1);
    wd:=TEXTOUT_P(STRING(value,1),115,86,2,0,144,white);
    FOR i FROM 1 TO d DO
      h:=h+CHAR(hc[s[i]+1]);
    END;

    RECT_P(wd,81,239,97); // clear the space after DEC
    wh:=TEXTOUT_P(h,115,100,2,0,144,white);
    RECT_P(wh,100,239,111); // clear the space after HEX

    IF value = 0 THEN
      115▶wd▶wh;
    END;
    IF he THEN
      RECT_P(wh,100,wh+6,111,0);
    ELSE
      RECT_P(wd,86,wd+6,97,0);
    END;
    key:=keys[WAIT(0)];
    CASE
      IF key=100 THEN
        RETURN "#"+h+"h";
      END;
      IF key >= 0 AND key < 10+he*9 or key=99 THEN
        ov:=value;
        value:=IFTE(key=99,IP(value/(10+6*he)),value*(10+6*he)+key);
        IF value>999999999999 THEN
          value:=ov;
        END;
      END;
      IF key=20 THEN // Apps changes the base
        he:=NOT he; //RECT_P(115,86,239,111); // unnecessary
      END;
      IF key=21 THEN   // Symb Key sets value to 0
        value:=0;
      END;
    END;
  UNTIL ISKEYDOWN(4);  //ESC will exit

  RETURN 46;  //one way to exit program with no apparent consequences
END;

KEY KS_Minus()
BEGIN
 intedit();
END;
Find all posts by this user
Quote this message in a reply
Post Reply 




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