2

We have a PDF document processing system, implemented in AppleScript (where we call the scripts from the shell using osascript). In some of the scripts, we call Acrobat Preflight Droplets from the Applescript.

This does usually work without problems. However, in some cases, where the processed document is big or/and complex. the droplet returns control to the script before the report is written and the document is moved to the "success" or "failure" folder. The consequence is that the process continues, but without the moved file, it eventually fails.

The workaround so far has been to add a delay after those droplet calls. This does help, but it is a waste of time for small documents, and there will always be a document big and complex enough to take longer than the delay.

We also found out that the time needed for finishing writing the report and moving the document depends on the speed of the system (had to be expected…).

The workaround would be to calculate the delay from the document size, its number of pages, and a machine-dependent parameter. Document size, and number of pages are no big deal; they can be retrieved in the Applescript.

The problem is the machine-dependent parameter, which can be determined experimentally. But how do I make that parameter available to all the scripts needing it?

Incorporating it into the scripts is not an option, because we have a number of systems installed, and if we would do that, we'd end up in a maintenance nightmare. Passing it as an argument in the initial system call is also not possible, because the calls are many, and again would lead to a maintenance nightmare.

So, is there a way to set up a place where that machine parameter can be stored and easily called from any Applescript, no matter how it itself is called.

Thanks a lot for your advice.

Max Wyss
  • 3,549
  • 2
  • 20
  • 26

2 Answers2

2

You might find the Property List Suite in System Events useful. It’s a standard means of storing and then retrieving such information. Property List files themselves are simply XML files, so you can even create them outside of AppleScript and then read them within your scripts.

There’s a description with examples at https://apple.stackexchange.com/questions/58007/how-do-i-pass-variables-values-between-subsequent-applescript-runs-persistent

Community
  • 1
  • 1
Jerry Stratton
  • 3,287
  • 1
  • 22
  • 30
0

A simple suggestion if you only have one paramater to keep track of would be to just have a text file in a known location on each machine. The only content of the text file would be the machine paramater. I like to use the Application Support folder this kind of thing.

Assuming your machine parameter is CPU speed. You can save a text file in /Library/Application Support/Preflight Scripts/machinecpu.txt with the contents:

2.4

Then in Applescript, you would just read the text file.:

set machineParam to read file "Macintosh HD:Library:Application Support:Preflight Scripts:machinecpu.txt"
Darrick Herwehe
  • 3,553
  • 1
  • 21
  • 30
  • Thanks for the hint. As the whole system is distributed using git, it is better within the range of the git directory. And in order to keep things open for more, the plist approach has some advantages. – Max Wyss Apr 03 '14 at 13:39