The Application Object
In Omni Automation, the OmniGraffle application object has properties (name, version) and elements (documents, stencils, windows). In a script, the application object is represented as: app
If you entered just “app” in the OmniGraffle console window and executed the line, the result would be a reference to the application object:
01 | app | |
02 | --> [object Application] |
To get the name of the OS the app is running on:
01 | app.platformName | |
02 | --> iOS or macOS |
Properties: name
The value of the name property of the application object is a string representing the name of the OmniGraffle application.
01 | app.name | |
02 | --> OmniGraffle |
The value of the application name property is read-only.
Properties: version
The value of the version property of the application object is a string representing the version number of the OmniGraffle application.
01 | app.version | |
02 | --> 177.0.276369 |
The value of the application version property is read-only.
To create a new version object:
01 | new Version('201.33') | |
02 | --> [object Version] |
To extract the version string from a version object:
01 | vers = new Version('201.33') | |
02 | vers.versionString | |
02 | --> 201.33 |
Comparing Versions
There are four methods you can use for comparing version objects:
Here are functions demonstrating their use:
Version Comparison Functions | ||
01 | function isBeforeCurVers(versStrToCheck){ | |
02 | curVers = app.userVersion | |
03 | curVersStr = curVers.versionString | |
04 | versToCheck = new Version(versStrToCheck) | |
05 | result = versToCheck.isBefore(curVers) | |
06 | console.log(versStrToCheck + ' is before ' + curVersStr + " = " + result) | |
07 | return result | |
08 | } | |
09 | ||
10 | function isEqualToCurVers(versStrToCheck){ | |
11 | curVers = app.userVersion | |
12 | curVersStr = curVers.versionString | |
13 | versToCheck = new Version(versStrToCheck) | |
14 | result = versToCheck.equals(curVers) | |
15 | console.log(versStrToCheck + ' equals ' + curVersStr + " = " + result) | |
16 | return result | |
17 | } | |
18 | ||
19 | function isAtLeastCurVers(versStrToCheck){ | |
20 | curVers = app.userVersion | |
21 | curVersStr = curVers.versionString | |
22 | versToCheck = new Version(versStrToCheck) | |
23 | result = versToCheck.atLeast(curVers) | |
24 | console.log(versStrToCheck + ' is at least ' + curVersStr + " = " + result) | |
25 | return result | |
26 | } | |
27 | ||
28 | function isAfterCurVers(versStrToCheck){ | |
29 | curVers = app.userVersion | |
30 | curVersStr = curVers.versionString | |
31 | versToCheck = new Version(versStrToCheck) | |
32 | result = versToCheck.isAfter(curVers) | |
33 | console.log(versStrToCheck + ' is after ' + curVersStr + " = " + result) | |
34 | return result | |
35 | } | |
36 |
This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.