Thanks for the link to Rob Trew’s paper. I had Googled for it but with no luck although I did discover some interesting posts by Mr. Trew on the Tinderbox Forum where I learned that Apple now describe Javascript as a peer of Applescript and that Applescript has probably been placed on care and maintenance (my description). So like it or not it seems that I am going to have to learn Javascript. {?}; Oh how I dislike all the punctuation of C like languages.
I’ll answer my own question : yes the tutorial is out of date, however, it is in a state of continuous review where the single author attempts to keep up with developments made by the Omni Group across all its applications. I am thankful that the site exists as it is an excellent resource as long as users, i.e. me understand that the screen shots may be from previous versions of the Omni Application we are using.
I have also managed to create my first, pointless plug-in which is listed below. I basically just tried what I had tried before and pressed the button at the top left of the console but this time Omnioutliner did not enter a loop of errors when I saved the updated script. So for anyone else who is struggling, here is a description of how I created my first working plugin having completed the tutorial.
a) Press the button ‘Add Action’ situated at top left of the console window. This will prompt for some fields to be populated e.g. Action Name, Organisation, Add to toolbar, text editor and lastly local or cloud storage. Enter some text but ensure that the ‘Add to toolbar’ is ticked. I selected BBEdit as my text editor as it provides syntax colouring of the script code.
b) Press the ‘Add’ button. This saves the new ‘action’ to the plugins folder. Once saved Omin Outliner will list the action in the Automation Menu and open the boiler plate script in your text editor.
c) Copy your working code from the console window and paste it below the comment line “// Add code to run …”
d) Save your masterpiece.
e) cross your fingers (not vital) and run the new action.
Here is my first action plugin
/*{
"author": "Simon Knight",
"targets": ["omnioutliner"],
"type": "action",
"identifier": "com.Skids.Toggle Display of Status",
"version": "0.1",
"description": "A plug-in that toggles the display of the status colum",
"label": "Toggle Display of Status",
"mediumLabel": "Toggle Display of Status",
"longLabel": "Toggle Display of Status",
"paletteLabel": "Toggle Display of Status",
}*/
(() => {
var action = new PlugIn.Action(function(selection) {
// Add code to run when the action is invoked
editor = document.editors[0]
tree = document.outline
StatusColVisible = editor.visibilityOfColumn(tree.statusColumn)
console.log("Status Col set to : ", StatusColVisible);
if (StatusColVisible) {
editor.setVisibilityOfColumn(tree.statusColumn, false);
} else {
editor.setVisibilityOfColumn(tree.statusColumn, true);}
console.log("Invoked with selection", selection);
});
// If needed, uncomment, and add a function that returns true if the current selection is appropriate for the action.
/*
action.validate = function(selection){
};
*/
return action;
})();
I have no idea what is happening in the boiler plate code e.g. (() => { is just the way it has to be ;-). My portion of script is based on code from the tutorial: I’ve added a third variable that is boolean and set to the visibility of the status column, this property is described in the API reference that is accessed from the console. Next I added a new console log because I was not sure that I was using the boolean correctly as it seems boolean may be a value and it is also a class. (and no I don’t understand the significance either).
Yes its pointless as it just duplicates a built in operation but it works. Big thanks to unlocked2412 and to the author of the tutorial site Sol.
best wishes
Simon