base conversion problems...
09-05-2017, 08:26 AM (This post was last modified: 09-05-2017 08:38 AM by webmasterpdx.)
Post: #13
 webmasterpdx Senior Member Posts: 541 Joined: Sep 2015
RE: base conversion problems...
I have a decent program for converting bases. I overloaded the # key (shift-3) in user mode. Note that there are problems with overloading the shift-minus (base function) which is unreliable, but shift-3 is reliable.
This must be run in Home mode as you can't push numbers of the form #nnb on the CAS stack.
So to use, you'd put it in Home mode, Enter your number and hit enter to push it onto the stack. Then shift-user, alpha-3 will run the program. Select the base you want to convert to via the menu. The program will exit itself.
It's pretty quick and easy to use.

First, here are some utility functions I use, including the key definition.

Code:
 // BASE CONVERSION KEY KA_3() BEGIN RETURN STRING(EVAL(MBase())); END; // DEFINE MENU EXPORT PUTMENU(mTXT) BEGIN DRAWMENU(mTXT(1),mTXT(2),mTXT(3),mTXT(4),mTXT(5),mTXT(6)); END; // SETS mSEL GLOBAL VIA MENU SELECT EXPORT GETMENU(mx,my,mTXT) BEGIN LOCAL mSEL; mSEL:=0; IF my≥220 AND my≤239 THEN CASE  IF mx≥0 AND mx≤51 AND mTXT(1)>"" THEN   mSEL:=1;  END;  IF mx≥53 AND mx≤104 AND mTXT(2)>"" THEN   mSEL:=2;  END;  IF mx≥106 AND mx≤157 AND mTXT(3)>"" THEN   mSEL:=3;  END;  IF mx≥159 AND mx≤210 AND mTXT(4)>"" THEN   mSEL:=4;  END;  IF mx≥212 AND mx≤263 AND mTXT(5)>"" THEN   mSEL:=5;  END;  IF mx≥265 AND mx≤319 AND mTXT(6)>"" THEN   mSEL:=6;  END; END; // CASE END; // IF MENU RETURN mSEL; END; // BEGIN

And here is the base conversion program itself.

Code:
 EXPORT MBase() BEGIN LOCAL men,m,m1,mx,my,s; // initialize men:={"","BIN","OCT","DEC","HEX","EXIT"}; PUTMENU(men); REPEAT // WAIT FOR A MOUSE CLICK  m:=WAIT(−1); UNTIL (m(1)==3 OR m(1)==7); mx:=m(2); my:=m(3); s:=GETMENU(mx,my,men); IF (s==1  OR s==6) THEN RETURN END; RETURN s:=SETBASE(Ans(1),s-1); END; // BEGIN

Enjoy...
 « Next Oldest | Next Newest »

 Messages In This Thread base conversion problems... - webmasterpdx - 09-01-2017, 10:24 AM RE: base conversion problems... - webmasterpdx - 09-01-2017, 11:47 AM RE: base conversion problems... - Helge Gabert - 09-01-2017, 05:24 PM RE: base conversion problems... - webmasterpdx - 09-02-2017, 03:23 AM RE: base conversion problems... - Helge Gabert - 09-02-2017, 05:34 AM RE: base conversion problems... - Joe Horn - 09-02-2017, 05:58 AM RE: base conversion problems... - Eddie W. Shore - 09-04-2017, 07:41 PM RE: base conversion problems... - Stevetuc - 09-02-2017, 08:27 AM RE: base conversion problems... - webmasterpdx - 09-02-2017, 10:15 AM RE: base conversion problems... - Stevetuc - 09-02-2017, 08:35 PM RE: base conversion problems... - webmasterpdx - 09-03-2017, 02:07 AM RE: base conversion problems... - leprechaun - 09-05-2017, 07:05 AM RE: base conversion problems... - webmasterpdx - 09-05-2017 08:26 AM RE: base conversion problems... - Stevetuc - 09-05-2017, 11:29 AM RE: base conversion problems... - webmasterpdx - 09-05-2017, 08:52 AM RE: base conversion problems... - webmasterpdx - 09-05-2017, 11:09 PM

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