Hello,
Recently, Michael challenged members of the forum to make a calculator. ( http://bbcbasic.co.uk/forum/viewtopic.p ... p=423#p423 )
I found some spare time this weekend and so I decided to have a go at the challenge.
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.
Edit: regrettably, I lost the files for the calculator program.
My calculator program
-
- Posts: 177
- Joined: Mon 02 Apr 2018, 21:51
My calculator program
Last edited by p_m21987 on Wed 26 Dec 2018, 16:25, edited 1 time in total.
-
- Posts: 78
- Joined: Sat 23 Jun 2018, 15:51
Re: My calculator program
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
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
-
- Posts: 177
- Joined: Mon 02 Apr 2018, 21:51
Re: My calculator program
Thanks for trying it out.
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
Yes. There are other similar problems as well. I'll definitely be improving on it.
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.Your library must let you make the button color different from the background doesn't it? That would enhance the appearance.
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.Since you have bags of space for buttons how about having the option of Hex entry and conversions to and from Decimal.
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
-
- Posts: 101
- Joined: Sat 23 Jun 2018, 19:52
Re: My calculator program
Nice calculator! You gonna add the + ?
Focus is on code subject. Feel free to judge the quality of my work.
-
- Posts: 177
- Joined: Mon 02 Apr 2018, 21:51
Re: My calculator program
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.