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

10.4: Add Programming to the Unit Converter widget System 10.4
This AppleScript patches the Apple-provided Unit Converter Widget to support a new Programming category that allows you to convert between Hex, Decimal, Octal, Binary and Char (ASCII). Simply paste it into your Script Editor and click Run. (If you ask yourself what those long lists of letters are in the source -- they are a diff file and a png encoded in base64.)

You'll then have to select the location of the stock Unit Converter Widget (which should be /Library/Widgets), select where to store the enhanced widget (just click OK for your home directory), and that's it. When you see three patch messages, select whether or not to install the new widget, and then click OK to install or click Cancel to keep it where you stored it.

Update: The script has been fixed -- sorry for the error!

[robg adds: I've tested this, and it worked as described. The modified widget is stored in your user's Library -> Widgets folder, so it doesn't overwrite the original.]
    •    
  • Currently 1.71 / 5
  You rated: 3 / 5 (7 votes cast)
 
[10,555 views]  

10.4: Add Programming to the Unit Converter widget | 11 comments | Create New Account
Click here to return to the '10.4: Add Programming to the Unit Converter widget' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Add Programming to the Unit Converter widget
Authored by: kainewynd2 on Jan 24, '07 05:38:43AM
I had an issue with compiling this script. It turned out that I needed to comment out the on error block. After that it seemed to work fine.

on patch(basedir, posixFilename, patchdata)
	try
		set patchResult to do shell script "cd " & (quoted form of basedir) & " ; (uudecode -p | patch -p0 ) <<-''" & return & patchdata
		
		(*on error errmsg number errnum
		if errnum ? 2 then
			display dialog errnum as string
		end if
		set patchResult to posixFilename & " is missing."
	end try*)
		return patchResult & return
	end try
end patch


[ Reply to This | # ]
10.4: Add Programming to the Unit Converter widget
Authored by: anonon on Jan 24, '07 08:41:55AM

i tried replacing the '?' with '=' in the errnum test
... i'm no applescript pro but it seemed logical

and it worked great



[ Reply to This | # ]
10.4: Add Programming to the Unit Converter widget
Authored by: kainewynd2 on Jan 24, '07 10:30:52AM

And, lo and behold, you were right. How novell...



[ Reply to This | # ]
10.4: Add Programming to the Unit Converter widget
Authored by: kainewynd2 on Jan 24, '07 10:32:00AM

or rather novel. Woo-hoo.



[ Reply to This | # ]
CORRECT FIX! Use option-equals!!
Authored by: Lectrick on Jan 24, '07 01:57:13PM
In the above referenced txt there is a question mark due to a possible encoding error of the character that is formed when you hold down option and press equals (≠). This is a standard applescript "not equals" operator.

So, if you really want to fix this without commenting out the error handling as suggested by others, change

if errnum ? 2 then

to

if errnum ≠ 2 then

Enjoy!

---
In /dev/null, no one can hear you scream

[ Reply to This | # ]

CORRECT FIX! Use option-equals!!
Authored by: Skeeve on Jan 25, '07 01:52:51AM

Oops! Didn't see that you already posted a correct fix. Thanks for that. Unfortunately a not-equal sign seems to be undisplayable here.



[ Reply to This | # ]
10.4: Add Programming to the Unit Converter widget
Authored by: Skeeve on Jan 25, '07 01:50:30AM

Actually it should have been a not-equal sign. It can be entered using /=.

That on-error part is for errors that might occure and which are not "File Exists" type of errors.



[ Reply to This | # ]
10.4: Add Programming to the Unit Converter widget
Authored by: robg on Jan 25, '07 05:17:26AM

I fixed the script; sorry for the error.

regards,
-rob.



[ Reply to This | # ]
10.4: Add Programming to the Unit Converter widget
Authored by: graemeaustin on Jan 24, '07 07:23:02AM

I had the same problem. But followed your patch and everything works fine.

Thanks!

Graeme



[ Reply to This | # ]
10.4: Add Programming to the Unit Converter widget
Authored by: fresler on Jan 24, '07 08:34:57AM

Very nice! I will find this extremely useful. Thanks!



[ Reply to This | # ]
10.4: Add Programming to the Unit Converter widget
Authored by: simonp on Jun 19, '10 07:07:41AM

Is there any chance of reviving this script? I had tried to make changes in the Snow Leopard version of the widget, and although it displays properly, the conversion does quite work...for example if values are entered on the left hand side of the window, the conversion occurs (HEX to DEC) but if a decimal number is entered on the right hand side (same settings, HEX to DEC) then the left hand side stays blank. Any help greatly appreciated.



[ Reply to This | # ]