Number Conversion

I’m sure the gurus here know this, but I just read in Hanaan Rosenthal’s book on AppleScript, this trick.

set myHex to "Ab4D"
set decEquiv to run script "parseInt( \"" & myHex & "\" , 16) " in "JavaScript"

This works for any base you plug in after the comma in the arguments for parseInt.

I never knew you could run JavaScript functions from an AppleScript.

I assume he’s referring to LNS’s JavaScriptOSA component. You can execute scripts written in any OSA language using ‘run script’ as long as you’ve the appropriate OSA language component installed. Better components should also allow you to pass input data via the ‘with parameters’ parameter.