Infix calculator

Talk about your programs in progress. Discuss how to implement features, etc.
Forum rules
This section is for testing Commander X16 programs and programs related to the CX16 for other platforms (compilers, data conversion tools, etc.)

Feel free to post works in progress, test builds, prototypes, and tech demos.

Finished works go in the Downloads category. Don't forget to add a hashtag (#) and the version number your program was meant to run on. (ie: #R41).
Post Reply
User avatar
TediusTimmy
Posts: 15
Joined: Tue Apr 25, 2023 3:54 am

Infix calculator

Post by TediusTimmy »

I have this in a state where I think I can show off some of it. Here's a calculator portion of the thing I'm working on. I'm working in C, and the code isn't in a state that I want to release it.

It's an eight digit decimal calculator. It uses infix notation. It is only a four-function calculator, though, but you can put parenthesis in. In the zip file is also the same program compiled for Windows (it is a C program after all). Just type in an expression and hit enter. It doesn't prompt you or anything. If you hit enter with a blank line, the program ends (or, if the line only has one character in it; I tried to fix that).

The numbers only truncate. The exponent range is small. The decisions for how to print numbers are arbitrary.

Try It Now!

#R42
Attachments
CalcDemo.zip
Zip file containing program in PRG form and also Windows executable, for the brave. (With fixed manifest extension.)
(33.07 KiB) Downloaded 201 times
Screenshot of it running in emulator.
Screenshot of it running in emulator.
ScreenShot.png (6.82 KiB) Viewed 3247 times
Last edited by TediusTimmy on Fri May 05, 2023 1:09 am, edited 1 time in total.
mobluse
Posts: 175
Joined: Tue Aug 04, 2020 2:16 pm
Location: Lund, Sweden
Contact:

Re: Infix calculator

Post by mobluse »

Try It Now doesn't work for me, but normally Try It Now works for me. I use Chromium in most updated Debian 11 Bullseye (aarch64) for Raspberry Pi 4B. Maybe it's because you included a Windows version and that might make the file too big. That's just one hypothesis.
X16&C64 Quiz: Try It Now! Huge Char Demo: Try It Now! DECPS: Try It Now! Aritm: Try It Now!
Edmond D
Posts: 489
Joined: Thu Aug 19, 2021 1:42 am

Re: Infix calculator

Post by Edmond D »

Try it now failed using Safari 16.4.1 on Mac OS 12.6.5 It may be the emulator is having an issue.

Looking via Safari's web inspector
Attachments
Screen Shot 2023-05-03 at 4.05.34 PM.png
Screen Shot 2023-05-03 at 4.05.34 PM.png (49.79 KiB) Viewed 3155 times
Screen Shot 2023-05-03 at 4.05.21 PM.png
Screen Shot 2023-05-03 at 4.05.21 PM.png (111.3 KiB) Viewed 3155 times
Screen Shot 2023-05-03 at 4.04.29 PM.png
Screen Shot 2023-05-03 at 4.04.29 PM.png (58.85 KiB) Viewed 3155 times
User avatar
Cyber
Posts: 482
Joined: Mon Apr 27, 2020 7:36 am

Re: Infix calculator

Post by Cyber »

TediusTimmy, manifest file should have json extention, not txt. So emulator is just ignoring your manifest, and loads all files from zip, then runs prg file. It's fine, but I think it's not what you wanted to do. )

Also I noticed that emulator not always runs the program. Seems there is problem with some async call, I'll look into it.
User avatar
TediusTimmy
Posts: 15
Joined: Tue Apr 25, 2023 3:54 am

Re: Infix calculator

Post by TediusTimmy »

@Cyber - Thank you. I forgot to rename the manifest file and never noticed. It should now be fixed in the OP.

I am going to also reupload it as the program file. If the other one fails, try this one.
Try It Now!
Attachments
calc-later.prg
Mostly the same as the other. There may be a few differences.
(17.57 KiB) Downloaded 247 times
mobluse
Posts: 175
Joined: Tue Aug 04, 2020 2:16 pm
Location: Lund, Sweden
Contact:

Re: Infix calculator

Post by mobluse »

I got both to work with Try It Now, but I had to press F9 many times to get the keyboard layout I use: en-gb. Otherwise I couldn't enter +, * etc. In the latest ROM after R42 F9 doesn't seem to work to change keyboard and I need to set keyboard layout using KEYMAP "EN-GB", but you cannot use KEYMAP in programs that start using Try It Now. Try It Now tries to identify the keyboard using the preferred language in the browser, but that doesn't match the keyboard in my case.
X16&C64 Quiz: Try It Now! Huge Char Demo: Try It Now! DECPS: Try It Now! Aritm: Try It Now!
Ender
Posts: 220
Joined: Sat May 09, 2020 9:32 pm

Re: Infix calculator

Post by Ender »

mobluse wrote: Sun May 07, 2023 1:09 pm I got both to work with Try It Now, but I had to press F9 many times to get the keyboard layout I use: en-gb. Otherwise I couldn't enter +, * etc. In the latest ROM after R42 F9 doesn't seem to work to change keyboard and I need to set keyboard layout using KEYMAP "EN-GB", but you cannot use KEYMAP in programs that start using Try It Now. Try It Now tries to identify the keyboard using the preferred language in the browser, but that doesn't match the keyboard in my case.
You can change the layout with the "menu" command and then "keyboard layout".

Edit: Nevermind, I just tried it in the web emu and it doesn't seem to work.... I guess that was added after R42.
Post Reply