Re: String to sum -- another method
Re: String to sum -- another method
- Subject: Re: String to sum -- another method
- From: Johnny AppleScript <email@hidden>
- Date: Tue, 12 Oct 2004 23:37:20 -0600
Title: Re: String to sum -- another method
OK, I took another run at man bc and saw what I was missing (though I still don't quite get the use of '/n') to make this work well for me; here's a sample handler for others interested; it can take any logical _expression_ of a mathematic problem, followed by the desired number of decimal points (in this case, 10) to return:
set theProblem to "(4+5) / 2.2"
set theResult to solveProblem(theProblem, 10)
return theResult
on solveProblem(p, f)
set theScale to "scale=" & (f as string) & "; "
set qt to "\""
set theMath to "echo " & qt & theScale & p & qt & " | bc"
do shell script theMath
end solveProblem
-- > "4.0909090909"
HTH -- JA
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden