XClose
List Archives : http://void.nothingness.org
List Archives

XTension Discussion

Can't set text item delimiters in global script?

From: Horst Brinker <horst-ml-AT-cox.net>
Date: 15 Oct 2014 15:42:27 UTC   (10:42:27 AM in author's locale)
To: xtensionlist <xtensionlist-AT-shed.com>
It’s been a truly fun weekend of delving into applescript and associated arcane arts. While trying to understand how to integrate my UPS with xtension, I tried James’ interface. But I also found Apcupsd. ( www.apcupsd.com )

Apcupsd provides hooks to run various shell scripts and commands on UPS events like power outages and battery failures. It also provides a wealth of data available from the UPS along with a utility that actually lets you set UPS variables like disabling the alarm beeping.

To integrate it with xtension, I’ve written a global script the runs the apcaccess shell command that provides output in the form of:

STATUS : ONLINE LINEV : 123.0 Volts
LOADPCT : 3.0 Percent
BCHARGE : 100.0 Percent
TIMELEFT : 130.6 Minutes

The full list is 37 lines of parameters long for my particular UPS. I wrote a global script to pull the parameters I want to reflect in pseudo units. It creates an AS list of the shell output with:

set apcData to the paragraphs of (do shell script "apcaccess”)

Then, I further parse the parameter and value in a repeat loop. Since apcaccess uses a “:” as a delimiter, I use that to parse each line with:

set text item delimiters to “:"

Strangely, this works fine in the applescript editor and the global script editor. However, when I save the global script and then try to just run it from the script menu, it throws this error:

Aug 10, 2014 3:17:17 PM Executing global script: ReadAPC
Aug 10, 2014 3:17:17 PM ReadAPCOSAError -10006: Can’t set text item delimiters to ":”.

I’m guessing running outside the editors puts me into some other context, but I’m too simple minded with applescript to know how to move forward with this.

Any help would be appreciated!
Horst
_______________________________________________
XTensionList mailing list
XTensionList-AT-shed.com
shed.com/mailman/listinfo/xtensionlist
.

* List Archives

The Graphics ListThe Situationist ListXTension Discussion
 

This site made manifest by Manifesto software

Page executed in 0.0099608898162842 seconds.
Loaded 202 classes from 6 of 10 total class files. Read 2 objects from the database. Served 2 items from the cache.
Queries - count: 2 select: 3 update: 1