Post Reply 
Entering the 'Edit Integer' window
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 


Messages In This Thread
RE: Entering the 'Edit Integer' window - matalog - 01-08-2024 11:14 PM



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