0

hope get help in this code;
its for a calculator

when the user press "=" that containing this script the answer should apear

at first of all i make sprite(2) as the space which the process will apera

this is my code ; it dose not work !!

on mousedown
  variable1=sprite(2).text
  global s
  s=variable1.word[2]
  global plase
  case (s) of
  "+ ": plase=variable1.word[1]+variable1.word[4]
  "*":multipl=variable1.word[1]*variable1.word[3]
  otherwise:put "wrong process" after sprite(2).member
end case
end

on mouseup
case (s) of 
"+":put plase after sprite(2).member
"*":put multipl after sprite(2).member
end case
end

let the process in sprite (2) be :
1*2=

[img]http://www.openiu.com/upload/071221/1372919869476c04581d7ed.GIF[/img]

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Zay
0

Two questions:

1. are you parsing the values before adding or multiplying them?

Right now, it looks like you are multiplying the 1 in your sample by the equal sign.

2. Are you taking into account different lengths of numbers?

I use a stack when I parse for a calculator, since ordinary arithmetic uses infix operators with algebraic precedence.

0

Two questions:

1. are you parsing the values before adding or multiplying them?

Right now, it looks like you are multiplying the 1 in your sample by the equal sign.

2. Are you taking into account different lengths of numbers?

I use a stack when I parse for a calculator, since ordinary arithmetic uses infix operators with algebraic precedence.

1- SURE , I PASE THE VALUES BEFORE PRESS EQUAL

there is something not ok here , with the '+' , when press it its apeear twice in the text field

so the code i wrote to it is a little bit diff. just to solve it now.

2- no, i just want to know the basic now and the method of how to do it with simple numbers

see what i did in this link :

http://hyperupload.com/download/026f95db26/CalculaterZahraa.dir.html

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.