Sal’s example AppleScripts have been around the internet for years and some were written before AppleScript had the extra commands bestowed upon it through its Standard Additions ( round for example). Set officeTempF to officeTemp as degrees Celcius as degrees Fahrenheit as number Tell application "JSON Helper" to fetch JSON from " set officeTemp to the result's state's temperature / 100 To summarise all of this, here’s one possible re-working of your script that incorporates the stuff above: to setDecimalPlaces for N to d as integer : 2 This doesn’t mean you can’t use these terms or assign things to them but you need to know when you can do this, and how to do it appropriately. You should be able to tell it’s a special word because, when you compile the script in Script Editor, it will appear in a specific font and colour that differentiates it as a being a pre-defined term. To this: tell application "JSON Helper" to fetch JSON from " tell state of resultĪs you will see, assigning something to the variable result is, at best, unnecessary, and in other cases, not a good idea, as result is a property in AppleScript that will always contain the output of the most recently executed line of a script. Set result to (fetch JSON from " tell state of result Lastly, I’d suggest changing this: tell application "JSON Helper" It’s not necessarily the best example of AppleScript’s so-called “natural language syntax”, so you might prefer to stick with the arithmetic. However, AppleScript is also familiar with various temperature scales, so it can perform the conversion for you if you prefer: set officeTempF to (officeTemp / 100) as degrees Celsius as degrees Fahrenheit as number To make the arithmetic less ambiguous to a casual reader, I would have written it like this: set officeTempF to (officeTemp / 100) * (9 / 5) + 32 You have a line in your script that converts a temperature value from Celsius to Fahrenheit: set officeTempF to (officeTemp / 100 * 9 / 5 + 32) Your number_to_string() handler, which seems to be there to cater for numbers expressed using scientific notation, is, therefore, superfluous, since AppleScript understands scientific notation already. Additionally, the "to" parameter is optional, and current is set to use 2 as the default value if omitted. You’ll notice that both parameters can accept a number or a string representation of a number, including one in scientific notation. It can be called in any of the following ways: setDecimalPlaces for 123.456543 to "2" Set x to (round N * k rounding as taught in school) / k Here’s an alternative method that’s shorter, faster, and less likely to error: to setDecimalPlaces for N to d as integer : 2 So, passing it number 123.456543 and specifying the number of decimal places as 3 returns 123.457, whilst specifying the number of decimal places as 4 returns 123.4565. For you, dear TUAW reader, I persevere.From what I can tell, your round_truncate() AppleScript handler outputs a number to a specified number of decimal places. GeekTool is strange enough about dragging Geeklets around, you don't want to try it on a network-attached monitor with a terrible refresh rate. I'll tell you outright that I don't recommend trying this, at least not using currently-available tools. Heaviest processes by memory and CPU usage.Calendar for the month with current day highlighted.These were dragged to the iPad to create a workable display configuration, including: Next, I opened up GeekTool 3 and duplicated a few of my Geeklets (little widgets that run shell commands and scripts to print data onto your desktop). That part was easy enough, and I found a few screen resolutions that work pretty well. I set up ScreenRecycler on my MacBook Pro and used iTeleport to turn my iPad into a third monitor. See the gallery for less-blurry images of the results. I'm sure there are a good number of people who could care less about this kind of thing, but ever since I saw Steve's post on Air Display, I started pondering the possibilities. Maybe add some news and weather, and your "Today" list from your favorite to-do app. Imagine this: you put your iPad into its dock next to your desktop (or laptop), and it transforms into a heads-up display of all the important stats from your machine.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |