calculation problem (with a homebrew calc)
BlitzPlus Forums/BlitzPlus Beginners Area/calculation problem (with a homebrew calc)
| ||
Global calc=CreateWindow("Captain's Calculator",0,0,200,300,0,1)
Global zero$="0"
Global one$="1"
Global two$="2"
Global three$="3"
Global four$="4"
Global five$="5"
Global six$="6"
Global seven$="7"
Global eight$="8"
Global nine$="9"
Global star$="*"
Global decimal$="."
Global minus$="-"
Global plus$="+"
Global divide$="/"
Global button_1=CreateButton(one$,0+20-3,50,50,25,calc,0)
Global button_2=CreateButton(two$,50+20,50,50,25,calc,0)
Global button_3=CreateButton(three$,100+20+3,50,50,25,calc,0)
Global button_4=CreateButton(four$,0+20-3,75+3,50,25,calc,0)
Global button_5=CreateButton(five$,50+20,75+3,50,25,calc,0)
Global button_6=CreateButton(six$,100+20+3,75+3,50,25,calc,0)
Global button_7=CreateButton(seven$,0+20-3,100+6,50,25,calc,0)
Global button_8=CreateButton(eight$,50+20,100+6,50,25,calc,0)
Global button_9=CreateButton(nine$,100+20+3,100+6,50,25,calc,0)
Global button_0=CreateButton(zero$,0+20-3,GadgetHeight(calc)-160,50,25,calc)
Global times=CreateButton("*",0+20-3,GadgetHeight(calc)-100,50,25,calc)
Global button_cls=CreateButton("CLR",GadgetWidth(calc)/2+25,GadgetHeight(calc)-100,50,25,calc)
Global InputArea=CreateTextArea(20,10,150,30,calc,0)
Global about_button=CreateButton("About",GadgetWidth(calc)/2-50,GadgetHeight(calc)-60,100,20,calc)
Global divides=CreateButton(divide$,50+20,GadgetHeight(calc)-100,50,25,calc)
Global slash=CreateButton(minus$,0+20-3,GadgetHeight(calc)-128,50,25,calc)
Global pluses=CreateButton(plus$,50+20,GadgetHeight(calc)-128,50,25,calc)
Global dot=CreateButton(decimal$,100+20+3,GadgetHeight(calc)-128,50,25,calc)
Global solve=CreateButton("Solve Equation!",50+20,GadgetHeight(calc)-160,103,25,calc)
Repeat
id=WaitEvent()
ClearTextArea(InputArea) : InputTextArea(InputArea)
Author()
;problem \/
If EventSource()=solve ;here
problem#=TextAreaText(InputArea) ;here
Print problem# ;here
EndIf
;problem /\
Select id
Case $803
End
End Select
Until KeyHit(1)
Function ClearTextArea(TextArea%)
If EventSource()=button_cls
SetTextAreaText(TextArea%,"")
EndIf
End Function
Function InputTextArea(TextArea%)
If EventSource()=button_1
AddTextAreaText(TextArea%,one$)
EndIf
If EventSource()=button_2
AddTextAreaText(TextArea%,two$)
EndIf
If EventSource()=button_3
AddTextAreaText(TextArea%,three$)
EndIf
If EventSource()=button_4
AddTextAreaText(TextArea%,four$)
EndIf
If EventSource()=button_5
AddTextAreaText(TextArea%,five$)
EndIf
If EventSource()=button_6
AddTextAreaText(TextArea%,six$)
EndIf
If EventSource()=button_7
AddTextAreaText(TextArea%,seven$)
EndIf
If EventSource()=button_8
AddTextAreaText(TextArea%,eight$)
EndIf
If EventSource()=button_9
AddTextAreaText(TextArea%,nine$)
EndIf
If EventSource()=times
AddTextAreaText(TextArea%,star$)
EndIf
If EventSource()=dot
AddTextAreaText(TextArea%,decimal$)
EndIf
If EventSource()=slash
AddTextAreaText(TextArea%,minus$)
EndIf
If EventSource()=pluses
AddTextAreaText(TextArea%,plus$)
EndIf
If EventSource()=divides
AddTextAreaText(TextArea%,divide$)
EndIf
If EventSource()=button_0
AddTextAreaText(TextArea%,zero$)
EndIf
End Function
Function Author()
If EventSource()=about_button
Notify("This Application was designed and written by Austin Wicker of Captain Wicker Software.",False)
ExecFile("http://www.captainwicker.com/")
EndIf
End Function
Can someone please tell me how to convert the TextArea to the sum number in my calculator project? Last edited 2012 |
| ||
| You mean, "all of the functionality of the project"? Protip: the "missing" bit accounts for more than 99% of the total code. This is ...well it's not "hard" in general terms, but it's definitely nontrivial for a beginner. Certainly I think you've underestimated the difficulty by a huge margin. Go to the code archives and search for "expression evaluator" (check back in a day or so for yet another one, I'm including one as a usage example with my next submission). ...also, I suggest learning about arrays. |