Author Topic: InForm Calculator  (Read 2764 times)

Offline TerryRitchie

  • Forum Resident
  • Posts: 611
  • 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.

Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 2224
  • LET IT = BE
    • QB64.org
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.                 BEEP
  3.  
  4.             CASE CHR$(22) '                                             CTRL-V paste
  5.                 BEEP

That'll work.

Offline TerryRitchie

  • Forum Resident
  • Posts: 611
  • 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.

Online TempodiBasic

  • Forum Resident
  • Posts: 1415
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.
Thanks for your Calculator
now I go to read code to enjoy of your comments


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

Offline TerryRitchie

  • Forum Resident
  • Posts: 611
  • 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.

Offline jack

  • Forum Regular
  • Posts: 240
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'
*_SUB_ALERT_SINGLE_S=(  float  )PlaySound((char*)(qbs_add(qbs_new_txt_len("SystemDefault",13),func_chr( 0 )))->chr,NULL, 65537 );

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 »

Offline johnno56

  • Forum Resident
  • Posts: 789
  • Live long and prosper.
Re: InForm Calculator
« Reply #6 on: August 31, 2018, 10:45:30 AM »
I had the same error.

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.

Offline jack

  • Forum Regular
  • Posts: 240
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

Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 2224
  • LET IT = BE
    • QB64.org
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?

Online TempodiBasic

  • Forum Resident
  • Posts: 1415
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)

sorry for my bad communication...

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

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

Offline TerryRitchie

  • Forum Resident
  • Posts: 611
  • 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.

Offline jack

  • Forum Regular
  • Posts: 240
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.

Offline jack

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

Offline jack

  • Forum Regular
  • Posts: 240
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. :)

Offline jack

  • Forum Regular
  • Posts: 240
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 »