Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use AppleScript as a simple calculator Apps
You can use AppleScript as a standard calculator in a pinch -- just type in the equation as you would normally, and leave out the = sign. The answer will be displayed in a window titled 'The Result.' For example, enter (663 * 24) / 2 and The Result will display 7956.0.

Now I know this is useless, but it proved helpful when I found out my beige G3 didn't have a calculator program!

[robg adds: If you're using Apple's Script Editor, just enter the equation as shown, then click Run to see the results at the bottom of the script editing window. And yes, it's mostly useless (but somewhat interesting) :).]
    •    
  • Currently 2.80 / 5
  You rated: 2 / 5 (5 votes cast)
 
[5,948 views]  

Use AppleScript as a simple calculator | 10 comments | Create New Account
Click here to return to the 'Use AppleScript as a simple calculator' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use AppleScript as a simple calculator
Authored by: mike3k on Aug 11, '04 12:00:19PM

I use bc in the terminal window instead. It works the same way.



[ Reply to This | # ]
bc eats decimals
Authored by: VRic on Aug 11, '04 02:15:51PM

Not the same. bc truncates decimals. I suppose there's an option somewhere but I doubt that's the default behavior most people expect from a calculator.

Examples:

Applescript (as typed/returned in Smile's worksheet -- spaces are added automatically around operators at runtime):
3 / 2
-- 1.5

bc (as typed/returned in Terminal, bc 1.05, Mac OS X 10.3.4):
3/2
1



[ Reply to This | # ]
Re: bc eats decimals
Authored by: sjk on Aug 12, '04 01:59:24PM
Try bc -l (dash-el).

[ Reply to This | # ]
Use AppleScript as a simple calculator
Authored by: adrianm on Aug 11, '04 02:12:22PM
This is a less useful part of a more useful and very well known hint using services: Type
(663 * 24) / 2
into any text field, say in Text Edit, and select it, then
cmd+*
(Services menu, Script Editor, Get Result Of AppleScript). Text is replaced with
7956.0
Of course, if you know applescript expressions, you can do some fairly clever things....

[ Reply to This | # ]
examples...
Authored by: adrianm on Aug 11, '04 02:26:59PM
for example:
tell application "Finder" to get name of every disk
or
(current date) as string


[ Reply to This | # ]
Use AppleScript as a simple calculator
Authored by: timcrawf on Aug 12, '04 08:44:34AM

but make a note to yourself command * is really
command-shift-8
Also, this will launch Script Editor



[ Reply to This | # ]
Use AppleScript as a simple calculator
Authored by: adrianm on Aug 12, '04 01:50:02PM

cmd+* for me is cmd key plus the * key (on the numeric keypad).

Yes, it does start script editor, but then the original hint required you to type the expression into it.



[ Reply to This | # ]
Use AppleScript as a simple calculator
Authored by: zane on Aug 12, '04 05:50:19PM
Google has become my full-time calculator & part-time unit conversion utility.

[ Reply to This | # ]
Use AppleScript as a simple calculator
Authored by: zane on Aug 12, '04 05:52:41PM
...which I should point out that you can utilize directly from Safari's built-in Google search box, to make this a Mac OS X hint. ;)

[ Reply to This | # ]
Use AppleScript as a simple calculator
Authored by: gibbonsb on May 16, '05 03:30:42PM
The Application Service for the Script Editor, "Get Result of AppleScript" no longer works for mathematical expressions as it did in Panther and earlier releases. It will still work for expressions like
say "who is the nimrod that broke that useful feature?"
but when evaluating mathematical expressions the answer no longer replaces the selected expression as it did before.

[ Reply to This | # ]