Unit property variable reported as undefined or having 0 value
Rob Lewis
rob at whidbey.com
Fri Oct 7 17:59:04 EDT 2016
I have a CAPACITY unit "Capacity in % of Battery". It has a numeric unit
property min_battery_percent, currently set to 40. But when I try to access
it, I get an error:
2016-10-07 13:41:54 Script error -2753: The variable min_battery_percent is
not defined.
>
This happens at startup, and also if I put this in the Command Line:
tell xUnit "Capacity in % of Battery" to write log (Get Unit Property
min_battery_percent)
>
Oh, wait, did I forget to enclose the property name in quotes?:
tell xUnit "Capacity in % of Battery" to write log (Get Unit Property
"min_battery_percent")
>
That causes this to be logged:
2016-10-07 13:46:24
>
Yep, just a timestamp. How about adding "as number"?
tell xUnit "Capacity in % of Battery" to write log (Get Unit Property
"min_battery_percent") as number
The log:
2016-10-07 13:47:18 0
>
Just a zero (actual value is 40). How about "as text"?
tell xUnit "Capacity in % of Battery" to write log (Get Unit Property
"min_battery_percent") as text
>
Result:
2016-10-07 13:52:31
>
Back to just the timestamp. What's going on here?
>
My only guess is that maybe there's something about having a percent sign
in the unit's name.
>
Ideas?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.machomeautomation.com/pipermail/xtensionlist/attachments/20161007/6738d784/attachment.html>
More information about the XTensionList
mailing list