### Author Topic: InForm Calculator  (Read 29331 times)

0 Members and 1 Guest are viewing this topic.

#### TerryRitchie

• Seasoned Forum Regular
• Posts: 495
• Semper Fidelis
##### InForm Calculator
« on: August 29, 2018, 11:48:46 pm »
I had fun learning to use InForm. Here is the calculator program I have been working on the past few days. There are still a few bugs in it (calculation errors due to QB64 giving results ending in .00000000000001 and some values coming up in scientific notation) and the Copy/Paste features are not operative. I still need to figure out how to get InForm to recognize when CTRL is pressed along with a keystroke when not on an active control.

Anyway, this little program gave me the general feel for InForm and got me back into programming QB64, a win-win.

« Last Edit: August 29, 2018, 11:50:17 pm by odin »
In order to understand recursion, one must first understand recursion.

#### FellippeHeitor

• Guest
##### Re: InForm Calculator
« Reply #1 on: August 30, 2018, 12:05:17 am »
That's really cool, Terry! I love the attention to detail with the history label!

BTW, because you're reading the keyboard with INKEY\$, __UI_CtrlIsDown will return -1 but you won't read "v" or "V" or "c" or "C", but instead CHR\$(22) for CTRL+V and CHR\$(3) for CTRL+C, as in DOS days:

Code: QB64: [Select]
1.             CASE CHR\$(3) '                                             CTRL-C copy
2.
3.             CASE CHR\$(22) '                                             CTRL-V paste

That'll work.

#### TerryRitchie

• Seasoned Forum Regular
• Posts: 495
• Semper Fidelis
##### Re: InForm Calculator
« Reply #2 on: August 30, 2018, 01:00:49 am »
Cool, I'll incorporate that. Thanks :)
In order to understand recursion, one must first understand recursion.

#### TempodiBasic

• Forum Resident
• Posts: 1792
##### Re: InForm Calculator
« Reply #3 on: August 30, 2018, 07:27:37 am »
Hi Terry
very cool
It brings me back in the windows  before this horrible w10.

Playing with your calculator I fall in this glitch (or feature?)
the first time that you make a SquareRoot I get in label operation (SQRT()) in an upper line  more result of  operation in a bottom line... this output stays during other operations while the line at bottom shows result of operations, if you use C then the squareroot in the upper line go away.

How to get this:
as first operation to do in calculator 1.0, or after another kind of operations if you
make 11*11 then press = and then SQR you get   SQRT(121)
11
or
write 144 and press SQR    you get   SQRT(144)
12
I attach screenshot image.

Programming isn't difficult, only it's  consuming time and coffee

#### TerryRitchie

• Seasoned Forum Regular
• Posts: 495
• Semper Fidelis
##### Re: InForm Calculator
« Reply #4 on: August 30, 2018, 12:02:03 pm »
Yes, that's how it works. I mimicked the history line exactly as the Windows 7 calculator performs it, so the results you are seeing are correct.
In order to understand recursion, one must first understand recursion.

#### jack

• Seasoned Forum Regular
• Posts: 408
##### Re: InForm Calculator
« Reply #5 on: August 31, 2018, 10:33:49 am »
my system is macOS High Sierra
I installed QB64 development version, it installed without complaints
I installed InForm beta 7 without complaints, however your Calculator fails to compile with the error

Quote
In file included from qbx.cpp:2179:
./../temp/main.txt:29110:33: error: use of undeclared identifier 'PlaySound'

if I comment-out where PlaySound is used, then I get the following error
Quote
ld: can't open output file for writing: ../../Calculator, errno=21 for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
« Last Edit: August 31, 2018, 10:42:48 am by jack »

#### johnno56

• Forum Resident
• Posts: 1270
• Live long and prosper.
##### Re: InForm Calculator
« Reply #6 on: August 31, 2018, 10:45:30 am »

Check out the "Inform" forum; "Library not found"; Page #1; Comment #12 (https://www.qb64.org/forum/index.php?topic=511.0)

Something to do with a windows api being called. I run with Linux and you with Mac. Who would have thought?...

Fellippe solved that issue... Let us know how you went?

J
Logic is the beginning of wisdom.

#### jack

• Seasoned Forum Regular
• Posts: 408
##### Re: InForm Calculator
« Reply #7 on: August 31, 2018, 11:10:06 am »
after following the suggestions by FellippeHeitor https://www.qb64.org/forum/index.php?topic=511.msg3615#msg3615 and https://www.qb64.org/forum/index.php?topic=511.msg3634#msg3634 I still get compile error 21

#### FellippeHeitor

• Guest
##### Re: InForm Calculator
« Reply #8 on: August 31, 2018, 11:11:42 am »
You say QB64 is working fine; does compiling other programs work without issue?

#### TempodiBasic

• Forum Resident
• Posts: 1792
##### Re: InForm Calculator
« Reply #9 on: August 31, 2018, 11:20:42 am »
Hi Terry
very cool Calculator 1.0 a clone of Window calculator (Calc.exe)

if the behaviour of Calc.exe of Windows 10 is like that of Windows 7 then there is a different behaviour of your beautyful Calculator 1.0 vs Windows calc.exe

in the issue,
if in calculator 1.0 I type 144 ->sqrt I get SQRT(144) 12  and this is ok
now
if I type 9 -->SQRT I get SQRT(144) 3
so I get no SQRT(9) and more when I type 9  the "SQRT(144)" stays still on display and also this is different from Windows' calc.exe
if I type 9 +1 =  I get SQRT(144) 10
so Calculator 1.0 has in memory still previous operation flag

Good Coding
Programming isn't difficult, only it's  consuming time and coffee

#### TerryRitchie

• Seasoned Forum Regular
• Posts: 495
• Semper Fidelis
##### Re: InForm Calculator
« Reply #10 on: August 31, 2018, 12:13:38 pm »
I'll need to look into that. I cobbled the program together pretty quickly as mainly an exercise to learn InForm. There are bound to be bugs here and there.
In order to understand recursion, one must first understand recursion.

#### jack

• Seasoned Forum Regular
• Posts: 408
##### Re: InForm Calculator
« Reply #11 on: August 31, 2018, 12:29:42 pm »
does compiling other programs work without issue?
I compiled and run 3dballs without problems, have not tried others.

#### jack

• Seasoned Forum Regular
• Posts: 408
##### Re: InForm Calculator
« Reply #12 on: August 31, 2018, 12:38:26 pm »
solved:
Code: QB64: [Select]
1. '\$INCLUDE:'Calculator.frm'
2.
to
Code: QB64: [Select]
1. '\$INCLUDE:'Calculator/Calculator.frm'
2.

#### jack

• Seasoned Forum Regular
• Posts: 408
##### Re: InForm Calculator
« Reply #13 on: August 31, 2018, 12:42:34 pm »
@TerryRitchie
the Return key works as the = button but the Enter key is ignored, I suggest that the Enter key also work as the = button. :)

#### jack

• Seasoned Forum Regular
• Posts: 408
##### Re: InForm Calculator
« Reply #14 on: August 31, 2018, 01:16:04 pm »
not Solved:
if after compile failure I Quit QB64 IDE and then relaunch, I get the popup "Recover program from auto-saved backup?"
I choose yes, QB64 then presents me with the calculator source, however it's titled as Untitled.
the IDE then tells me that Calculator.frm is not found, then if I change it to Calculator/Calculator.frm it then compiles the and runs the program OK
but only if I leave the name as Untitled.bas
just now QB64 crashed on me when I right-clicked on some highlighted text, trying to relaunch several times failed.
« Last Edit: August 31, 2018, 01:23:39 pm by jack »