The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   AppleScripting Omni Apps (http://forums.omnigroup.com/forumdisplay.php?f=46)
-   -   Omni code golf (http://forums.omnigroup.com/showthread.php?t=20555)

RobTrew 2011-03-30 11:49 AM

Omni code golf
 
The scriptability of Omni apps is excellent, and I find that it makes them really invaluable.

Even excellence benefits from a challenge, of course, and in honour of the ancient tradition of [URL="http://bit.ly/PerlGolf"]Perl golf[/URL] I have just taken a round of some of the Omni Apps, in search of the shortest applescript program that can solve a particular problem.

The obvious starting problem is simply a test of robustness - what is the smallest number of characters that can be used in Applescript to crash the application ?

At the moment OO3 (my favourite application, as it happens) is leading the field with just 84 characters:

[CODE]tell application id "OOut" to tell row 1 of document 1 to move it to end of children[/CODE]

OmniFocus comes in next at 92:

[CODE]tell application id "OFOC" to tell flattened task 1 of document 1 to move it to end of tasks[/CODE]

OmniPlan is a harder challenge - the following code does not crash the application, but does seem to unexpectedly eliminate a task.

[CODE]tell application id "OPla" to tell task 1 of document 1 to move it to end of tasks[/CODE]

OmniGraffle Professional 5 comes in last in the race to crash, and, perhaps most robustly and impressively of all, actually generates an error message [I]OmniGraffle Professional 5 got an error: AppleEvent handler failed.[/I] in response to the following:

[CODE]tell application id "OGfl" to tell incoming line 1 of shape 1 of canvas 1 of document 1 to move it to end of incoming lines[/CODE]

(All of the above assume that there is a document containing at least one row task or shape, and the OG code assumes that Shape 1 has an incoming line).

(Disclaimer - I do not advise the testing of any of these code snippets - they may cause loss of data).

[COLOR="White"]--[/COLOR]

Brian 2011-03-30 04:05 PM

Nice work. Misbehaviors all reproduced and written up. Thanks!


All times are GMT -8. The time now is 04:59 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.