tag:blogger.com,1999:blog-5314745381778741517.post6858067028818508221..comments2019-02-19T03:07:19.114+00:00Comments on LazPlanet: A simple calculator projectAdnan Shameemnoreply@blogger.comBlogger2125tag:blogger.com,1999:blog-5314745381778741517.post-47598210574359767292013-11-05T08:48:38.587+00:002013-11-05T08:48:38.587+00:00Carmelo
"As i look your articles sometimes i...Carmelo<br /><br />"As i look your articles sometimes i wonder if is it possible to do something...:)"<br />Well, this is one of the characteristics of a good programer. If you want to learn something as a programer, you need to think further of the possibility of enhancing the code. Learning is whole lot fun that way.<br /><br />If you want to process text in a single TEdit, then you will have to learn to go through the input and process it. Expressions can also be of complex structure, such as: (1+2)*(6/3).<br /><br />It seems like a complex problem, But there are algorithms to solve these infix expressions. As a part of my graduation course I was taught a book titled "Data Structures" written by Saymour Lipschutz. I had some knowledge regarding processing the expressions through algorithms. But today, after two years, I am not that sure about the knowledge! The book says: "The computer usually evaluates an arithmetic expression written in infix notation in two steps. First, it converts the expression to postfix notatiobn, and then it evaluates the postfix expression. In each step, the stack is the main tool that is used to accomplish the given task."<br /><br />So, you will have to have good understanding about stacks, arrays, binary trees, infix notations, postfix expressions and may be polish notation as well. Infix notation is where operators (^,+,-,*,/) are in the middle of numbers. e.g. 1+2 7*2. We generally write arithmetic expressions that way. "Postfix also known as Reverse Polish Notation (or RPN), is a notational system where the operation/function follows the arguments. For example, "1 2 add" would be postfix notation for adding the numbers 1 and 2." <a href="http://c2.com/cgi/wiki?PostfixNotation" rel="nofollow">(source)</a><br /><br />A Data Structure book can help you on this regard to learn about the process in more detail. I'll try to write about it if I get time and interest (!) to revise it. But till then read this: <a href="http://kd5col.info/swag/PARSING/0011.PAS.html" rel="nofollow">"Infix to Postfix expression parser" by CLIF PENN</a> . If you get it after reading once, then you are lucky! If not, read some books!<br /><br />Another way is to use a TEdit to enter only the numbers, same as calculators. User will enter a number. When he clicks a operator the number would be taken in a variable and TEdit will be cleared, then the user will enter another number. And when the [=] button will be pressed, the result will be calculated and shown.<br /><br />Regards<br />AdnanAdnan Shameemhttps://www.blogger.com/profile/03795435968155667026noreply@blogger.comtag:blogger.com,1999:blog-5314745381778741517.post-3386520343278411752013-11-04T11:09:54.656+00:002013-11-04T11:09:54.656+00:00hi Adnan!
As i look your articles sometimes i wond...hi Adnan!<br />As i look your articles sometimes i wonder if is it possible to do something...:)<br />So, from this article i wonder:<br />Is it possible to create a calculator using only one Tedit?<br />For exemple, if i type two number in one edit (for example "4+5") is it possible to get the result?<br />Regards <br />CarmeloCarmelo Priviterahttps://www.blogger.com/profile/17269109300030706712noreply@blogger.com