My calculator program

Discussions related to mathematics, numerical methods, graph plotting etc.
Post Reply
Patrick M
Posts: 99
Joined: Mon 02 Apr 2018, 21:51

My calculator program

Post by Patrick M » Sat 15 Sep 2018, 12:53

Hello,

Recently, Michael challenged members of the forum to make a calculator. ( viewtopic.php?f=7&t=101&p=423#p423 )
I found some spare time this weekend and so I decided to have a go at the challenge.

Image

The calculator uses my simple GUI library that I posted on the forum a few months ago.
For the past few years I've been using a program called 'gnome calculator' that has some features that I use a lot and have come to rely upon - the ability to define variables (e.g. you can write stuff like "width =100" and "height = 500" and then "area = width*height"), and the ability to look at and toggle the bits in an integer.
So I decided to try to add those features to my calculator program.

I haven't tested it very thoroughly yet so it's likely that it has serious bugs or flaws. I've tried to catch errors but it might still be possible to get the program to crash completely.
It also doesn't have history, which a good calculator really should have. So I might go back and add a history/undo/redo later on.

Here is the calculator program along with the GUI library that's necessary for it to work:
http://dusthillguy.ddns.net/folder/file ... ewcalc.zip

Let me know what you think.

Patrick
P.M.

Zaphod
Posts: 45
Joined: Sat 23 Jun 2018, 15:51

Re: My calculator program

Post by Zaphod » Sun 16 Sep 2018, 02:00

An interesting example.
Have you noticed that when you put in a number after an evaluation it tags it onto the previous result in the display?
Your library must let you make the button color different from the background doesn't it? That would enhance the appearance.
Since you have bags of space for buttons how about having the option of Hex entry and conversions to and from Decimal.

Z

Patrick M
Posts: 99
Joined: Mon 02 Apr 2018, 21:51

Re: My calculator program

Post by Patrick M » Sun 16 Sep 2018, 21:08

Thanks for trying it out.
Zaphod wrote:
Sun 16 Sep 2018, 02:00
Have you noticed that when you put in a number after an evaluation it tags it onto the previous result in the display?
Yes. There are other similar problems as well. I'll definitely be improving on it.
Your library must let you make the button color different from the background doesn't it? That would enhance the appearance.
My library doesn't have that feature at the moment. I could add it, but I'm not sure if I will. I personally like the colours of GUI objects to be uniform.
Since you have bags of space for buttons how about having the option of Hex entry and conversions to and from Decimal.
Ah, well, there's already the hexadecimal display when the result is an integer. I intend to improve on that by making it possible to copy the hexadecimal number to the clipboard.
And since the calculator program is (for the most part) very simply accepting strings and asking the BASIC interpreter to evaluate them, it already has hex entry - you just type your hex numbers with the & prefix as you would usually do in a BBC BASIC program.

I might add more buttons though, we'll see.

PM
P.M.

mikeg
Posts: 32
Joined: Sat 23 Jun 2018, 19:52

Re: My calculator program

Post by mikeg » Wed 19 Sep 2018, 03:04

Nice calculator! You gonna add the + ?

Patrick M
Posts: 99
Joined: Mon 02 Apr 2018, 21:51

Re: My calculator program

Post by Patrick M » Thu 20 Sep 2018, 15:00

mikeg wrote:
Wed 19 Sep 2018, 03:04
Nice calculator! You gonna add the + ?
Thanks!
Whoops, I didn't notice that + was missing. I might actually remove the buttons completely (except for Evaluate and Clear) and use the free space to show a history list. I never really intended for the buttons to be used much, since I find it much more convenient to type in calculations with the keyboard.
P.M.

Post Reply