<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
-- These properties specify the possible actions to take.
-- To add other functions, such as exponention, define it here
-- and add a handler in the DoCalc() and ParseStr() functions.
property doDivide : <font color = red>"/"</font>
property doMultiply : <font color = red>"*"</font>
property doAdd : <font color = red>"+"</font>
property doSubtract : <font color = red>"-"</font>
-- here's our string
set stringToCalc to <font color = red>"<font color = blue>1</font>+<font color = blue>1</font>"</font>
set theResult to parseStr(stringToCalc)
get ((stringToCalc & <font color = red>" = "</font> & theResult) as string)
on doCalc(operation, num1, num2)
-- This function takes an operation and two numbers or strings and calculates the result.
set operand1 to <font color = blue>0</font>
set operand2 to <font color = blue>0</font>
-- Parse the first num to decide <font color = green>if</font> it's a string or a number we can work with
-- Assume we don't have a number
set gotOp1 to false
-- and keep going until we <font color = green>do</font>
repeat until gotOp1 is true
try
-- see <font color = green>if</font> AppleScript can type the parameter to a number
set operand1 to num1 as number
-- <font color = green>if</font> we get here we have a number
set gotOp1 to true
on error
-- <font color = green>if</font> we get here we have a string, so parse the string out again
set num1 to parseStr(num1 as string)
end try
end repeat
-- now, repeat the entire process again <font color = green>for</font> the second operand
set gotOp2 to false
repeat until gotOp2 is true
try
set operand2 to num2 as number
set gotOp2 to true
on error
set num2 to parseStr(num2 as string)
end try
end repeat
-- by the time we get here, we have two numbers (operand1 and operand2)
-- so we can perform the calculation based on the operation parameter
<font color = green>if</font> operation = doDivide then
set theResult to operand1 / operand2
<font color = green>else</font> <font color = green>if</font> operation = doMultiply then
set theResult to operand1 * operand2
<font color = green>else</font> <font color = green>if</font> operation = doAdd then
set theResult to operand1 + operand2
<font color = green>else</font> <font color = green>if</font> operation = doSubtract then
set theResult to operand1 - operand2
<font color = green>else</font>
set theResult to <font color = blue>0</font>
end <font color = green>if</font>
<font color = green>return</font> theResult
end doCalc
on parseStr(theStr)
-- first check to see <font color = green>if</font> the string can be classed as a number
try
set theNum to theStr as number
-- <font color = green>if</font> we get here, AppleScript can convert theStr to a number, so we don't need to <font color = green>do</font> anything
<font color = green>return</font> theNum
on error
-- <font color = green>if</font> we get here, theStr is, indeed, a string
end try
-- first check <font color = green>for</font> division
<font color = green>if</font> class of theStr is string then
-- see <font color = green>if</font> theStr contains a <font color = red>"/"</font> character
set dividePos to offset of <font color = red>"/"</font> in theStr
<font color = green>if</font> dividePos > <font color = blue>0</font> then
-- now split the string at the <font color = red>"/"</font> character
set numerator to characters <font color = blue>1</font> through (dividePos - <font color = blue>1</font>) of theStr as string
set denominator to characters (dividePos + <font color = blue>1</font>) through <font color = blue>-1</font> of theStr as string
-- and calculate the result
set theResult to doCalc(doDivide, numerator, denominator)
end <font color = green>if</font>
end <font color = green>if</font>
-- now check <font color = green>for</font> multiplication
<font color = green>if</font> class of theStr is string then
set multPos to offset of <font color = red>"*"</font> in theStr
<font color = green>if</font> multPos > <font color = blue>0</font> then
set num1 to characters <font color = blue>1</font> through (multPos - <font color = blue>1</font>) of theStr as string
set num2 to characters (multPos + <font color = blue>1</font>) through <font color = blue>-1</font> of theStr as string
set theResult to doCalc(doMultiply, num1, num2)
end <font color = green>if</font>
end <font color = green>if</font>
-- now check <font color = green>for</font> addition
<font color = green>if</font> class of theStr is string then
set addPos to offset of <font color = red>"+"</font> in theStr
<font color = green>if</font> addPos > <font color = blue>0</font> then
set num1 to characters <font color = blue>1</font> through (addPos - <font color = blue>1</font>) of theStr as string
set num2 to characters (addPos + <font color = blue>1</font>) through <font color = blue>-1</font> of theStr as string
set theResult to doCalc(doAdd, num1, num2)
end <font color = green>if</font>
end <font color = green>if</font>
-- now check <font color = green>for</font> subtraction
<font color = green>if</font> class of theStr is string then
set subPos to offset of <font color = red>"-"</font> in theStr
<font color = green>if</font> subPos > <font color = blue>0</font> then
set num1 to characters <font color = blue>1</font> through (subPos - <font color = blue>1</font>) of theStr as string
set num2 to characters (subPos + <font color = blue>1</font>) through <font color = blue>-1</font> of theStr as string
set theResult to doCalc(doSubtract, num1, num2)
end <font color = green>if</font>
end <font color = green>if</font>
<font color = green>return</font> theResult
end parseStr</font>[/code]
Wow, it works. I didn't exactly want it to return as a dialog but I fixed that

Thanks alot. I'll add a few things and that get it to do what I want. Again, thank you.
synotic@mac.com