Hey guys, i've been trying to make a calculator with some simple functionality like addition subtraction etc, but have got a jumbled mess of a code. what is wrong, and could someone help out with correcting the messed up areas. From there i am hoping to add square roots and sin cos and tan functionality. below is the code i have so far.
Any help at all would be greatly appreciated.
hide mouse
clear entry buffer
Global FirstNum as Float
Global SecondNum as Float
Global Userinput as string
Global Userinput2 as string
Global returnkey as integer
Center text 320, 10, " The Calculator of calculators. "
ThatPart:
cls
input "First num: ",a#
Userinput = entry$(1)
CENTER TEXT 320, 50, a#
If key = 71 or key = 72 or key = 73 or key = 75 or key = 76 or key = 77 or key = 79 or key = 80 or key = 81 or key = 82
FirstNum = val(Userinput)
endif
if FirstNum > 0 and key=78 then add()
if FirstNum > 0 and key=74 then subtract()
if FirstNum > 0 and key=53 then divide()
if FirstNum > 0 and key=55 then multiply()
`if FirstNum > 0 and key=54 then power()
`if FirstNum > 0 and key=56 then sqroot()
Printer()
sync
Function Printer()
center text 320,200, "The FirstNum is " +str$(FirstNum)
center text 320,210, "The SecondNum is" + str$(SecondNum)
center text 320,220, "Enterkey = " + str$(returnkeystate)
goto ThatPart
endfunction
Function add()
cls
clear Entry Buffer
do
cls
Userinput = entry$(1)
key = scancode()
Userinput = entry$(1)
center text 320, 10, "Enter Your desired number that you want to do this to " + Userinput
If key = 71 or key = 72 or key = 73 or key = 75 or key = 76 or key = 77 or key = 79 or key = 80 or key = 81 or key = 82
SecondNum = val(Userinput)
endif
if returnkey() = 1
FirstNum = FirstNum + SecondNum
goto ThatPart
endif
Printer()
sync
loop
endfunction SecondNum
Function subtract()
cls
clear Entry Buffer
do
cls
Userinput = entry$(1)
key = scancode()
Userinput = entry$(1)
center text 320, 10, "Enter Your desired number that you want to do this to " + Userinput
If key = 71 or key = 72 or key = 73 or key = 75 or key = 76 or key = 77 or key = 79 or key = 80 or key = 81 or key = 82
SecondNum = val(Userinput)
endif
if returnkey() = 1
FirstNum = FirstNum - SecondNum
goto ThatPart
endif
Printer()
SYNC
LOOP
endfunction SecondNum
Function divide()
cls
clear Entry Buffer
do
cls
Userinput = entry$(1)
key = scancode()
Userinput = entry$(1)
center text 320, 10, "Enter Your desired number that you want to do this to " + Userinput
If key = 71 or key = 72 or key = 73 or key = 75 or key = 76 or key = 77 or key = 79 or key = 80 or key = 81 or key = 82
SecondNum = val(Userinput)
endif
if returnkey() = 1
FirstNum = FirstNum / SecondNum
goto ThatPart
endif
Printer()
sync
loop
endfunction SecondNum
Function multiply()
cls
clear Entry Buffer
do
cls
Userinput = entry$(1)
key = scancode()
userinput = entry$(1)
center text 320, 10, "Enter Your desired number that you want to do this to " + Userinput
If key = 71 or key = 72 or key = 73 or key = 75 or key = 76 or key = 77 or key = 79 or key = 80 or key = 81 or key = 82
SecondNum = val(Userinput)
endif
if returnkey() = 1
FirstNum = FirstNum * SecondNum
goto ThatPart
endif
Printer()
sync
loop
endfunction SecondNum
wait key
Bow Chika Bow Wow