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]

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.