LoginLogin

Stack calculator

Root / Submissions / [.]

SquareFingersCreated:
Download:NRXJ14MD
Version:V0.05Size:18.9KB
A stack-based calculator, with macros. In a stack-based calculator, parentheses are not used. Values are added to the stack, then operations are performed on the top element(s) of the stack. For instance, 5+3 becomes: 5 (enter) 3 +. 5 and 3 will disappear from the stack, to be replaced with 8. (2+7)*(10-4) becomes 2 (enter) 7 + 10 (enter) 4 - *. The first operation to be computed is addition, so the first operation you type is +,when you have 2 and 7 at the top of the stack. The second operation to be computed is subtraction, so the second operator you type is -, after putting 10 and 4 on the stack. The last operation to be computed is multiplication, so the last operator you type is *. In this calculator, sequences of operations can be recorded as macros, and played back with a single tap on the touchscreen.

Instructions:

Tap numbers and operations on the touchscreen. The stack is shown on the top screen. Tap the 'HELP' button for more help.

If you get the time, you should explain how stack-based calculators work (or maybe even explain it in the program somehow). I think it's an excellent programming example.

So it's just a reverse-polish notation calculator? Perhaps it could convert from infix to polish notation. Like, you input an infix notation calculation and it spits out the reverse-polish equivalent, and vise versa.

Replying to:haloopdy
If you get the time, you should explain how stack-based calculators work (or maybe even explain it in the program somehow). I think it's an excellent programming example.
Thank you. V0.02 has built-in help. Not much, but it's something.

Replying to:MZ952
So it's just a reverse-polish notation calculator? Perhaps it could convert from infix to polish notation. Like, you input an infix notation calculation and it spits out the reverse-polish equivalent, and vise versa.
So it's ... a reverse-polish notation calculator? Yes, that's what it is. It's not a translator from one language to another (infix to suffix) - that's a rather different type of program. It now has macros, though. If there's an operation you can perform by always tapping the same sequence of keys on the calculator, you can record that sequence, and play it back with a single tap on the touchscreen.

I really love how the macros work! Good work!

Replying to:hakke
I really love how the macros work! Good work!
Thanks. I particularly like the roll-a-die macro I describe in the help. I don't know why really, it's not all that clever, but I do like it.

Replying to:hakke
I really love how the macros work! Good work!
I also like how the program is easy to read thanks to the button engine. :)

This is really neat. I've always liked RPN calculators; it feels more hands-on with the calculating process (even though it does require more keystrokes and finger gymnastics sometimes.) More like I'm operating a calculating machine than I'm telling a computer to do my math for me. The macro keys are a great addition. What would be nice is the ability to save them to a file; in case someone happens to use this as a dedicated calculator, we wouldn't want them losing their macros every time. Giving them short names would be nice as well, but I don't know how you would work that into the interface.

Replying to:snail_
This is really neat. I've always liked RPN calculators; it feels more hands-on with the calculating process (even though it does require more keystrokes and finger gymnastics sometimes.) More like I'm operating a calculating machine than I'm telling a computer to do my math for me. The macro keys are a great addition. What would be nice is the ability to save them to a file; in case someone happens to use this as a dedicated calculator, we wouldn't want them losing their macros every time. Giving them short names would be nice as well, but I don't know how you would work that into the interface.
I wondered if saving the macros was a feature I should add... then I thought, nah. Well, V0.05 now saves the macros.

When you load the macros in MACLOAD, you try to load the macro file, and then check RESULT to see if it actually worked. You should instead do:
IF CHKFILE(MACFILENAME$) THEN
 MACFILE$=LOAD("TXT:"+MACFILENAME$,FALSE)
 ELSE RETURN
ENDIF
No more ugly load failure prompt when you boot it up without a macro file. It also looks cleaner IMO.

Replying to:snail_
When you load the macros in MACLOAD, you try to load the macro file, and then check RESULT to see if it actually worked. You should instead do:
IF CHKFILE(MACFILENAME$) THEN
 MACFILE$=LOAD("TXT:"+MACFILENAME$,FALSE)
 ELSE RETURN
ENDIF
No more ugly load failure prompt when you boot it up without a macro file. It also looks cleaner IMO.
Good suggestion, thanks. I'll do that for the next release.