Adium
Dock Icons Emoticons Contact List Styles Message Styles Sound Sets AppleScripts Status Icons Service Icons Menu Bar Icons Plugins Miscellaneous All
Math

Math

Submitted By Martin Crisp (Hypercube)

Description

Info updated for v1.1

%_math{ArithmeticExpression}
for use anywhere.

/math{ArithmeticExpression}
for use at the start of a message only.


returns the result of AritmeticExpression

supports: +, -, /, ?, *, ^ (exponentiation), div (integer division) and mod (remainder from integer division) operators, as well as almost any AppleScript syntax.

Allows parentheses for changing evaluation order; e.g.
2*2+2 => 6 vs 2*(2+2) => 8

Limitations:
Only supports AppleScript's built in arithmetic, which includes any arithmetic (or other) functions provided by installed 'Scripting Additions' on your Mac.

Examples:
%_math{-1+2^(23)} sends: 8388607
%_math{pi} sends: 3.141592653589793
%_math{round (17?2.4*1.17) rounding as taught in school} sends: 8
%_math{round (17?2.4*1.17) rounding to nearest} sends: 8
%_math{round (17?2.4*1.17) rounding up} sends: 9
%_math{round (17?2.4*1.17) rounding down} sends: 8
%_math{length of "hello" * length of "john"} sends: 20

Have Fun
Martin

Comments

You can reply to individual comments by clicking the "Reply" link next to each.

# by tim on 09/11/04 at 12:00:06

Thank you!! I was about to make something like this myself.

# by on 11/11/04 at 12:41:36

Nice, but could you change it to /math{expression} instead? Its a bit faster to type..

# by Hypercube on 11/11/04 at 21:53:00

Sure. But I prefer it as is. :-)

To add that ability would make more sense :-)

Watch This Space ;-)
(offer void where prohibited; subject to availability of resources, particularly time).

Have Fun
Martin

# by Hypercube on 11/11/04 at 23:28:21

Done.

Note: The v1.1 is pending approval. The above is the only addition in functionality. The 'general AppleScript' ability was there previously, just not as strongly emphasised.

Have Fun
Martin

# by Hypercube on 11/12/04 at 22:10:20

Guess who didn't notice the 'not visible while pending' note :-/

# by on 11/22/04 at 15:26:46

AahHH.. Now I see. I thought you could have /math{} inside a sentence! But /math is nice to have too though.. :)

I guess im quite an annoyance.. But is it possible to change %_math into %math? ;) Its just that, the faster you can type it, the more I'll use it! :)

# by Hypercube on 11/22/04 at 21:51:11

Well... for consistency's sake, I'd rather not alter the downloadable copy. So here is what you need to do to 'fix' your copy...

1) Find the downloaded copy of the .AdiumScript bundle
2) control-click on the bundle, choose "Show Package Contents" from the contextual menu
- a new folder window will open, showing a folder named "Contents".
3) open the "Contents" folder
4) Inside the "Contents" folder is a file called "Info.plist", double-click it.
- It will either open in TextEdit, or in the Property List Editor (depending on whether you have DevTools/XCode installed, or not). In either case...
5) Find the entry in the 'Script' dictionary which identifies the Keyword. Change the 'value' that corresponds to the Keyword from %_math to %math.
6) Save your changes
7) install the bundle.
---
If any of the above is too brief, email me, and we can take it further there.

HTH
Have Fun
Martin


# by Hypercube on 11/22/04 at 21:58:14

Addendum: In step 5, there are 2 'Scripts' dictionaries, the %_math is the second one :-)

Post a New Comment

You must be logged in to post comments.

Install | Download
5.65kb (773 downloads)

12345
2.90 / 111 votes
Current Version: 1.1
Last Updated: 11/11/04
Credits:
Spitty27's Calculator script, as posted in funmac forums.