User Tools

Site Tools


dictionary:unitinformation:enumeratedvalue

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Last revisionBoth sides next revision
dictionary:unitinformation:enumeratedvalue [2023/02/13 14:52] – external edit 127.0.0.1dictionary:unitinformation:enumeratedvalue [2023/05/20 14:47] – added optional for parameter James Sentman
Line 1: Line 1:
 =====Enumerated Value Of===== =====Enumerated Value Of=====
-The **Enumerated Value Of** verb returns a string equal to the enumerated value of a unit if available and in range or an apple script error if it is not. Examples of units that could be enumerated might be a thermostat mode unit which could be “off, heat, cool, auto” or a garage door unit that could be “open, closed” + 
 +**Enumerated Value Of “Name of Unit” (optional) for (integer value to get enumeration for)**\\ 
 +returns string, or script error if value is out of range for available enumerations 
 + 
 + 
 +The **Enumerated Value Of** verb returns a string equal to the enumerated value of a unit if available and in range or an apple script error if it is not. Examples of units that could be enumerated might be a thermostat mode unit which could be “off, heat, cool, auto,” a garage door unit that could be “open, closed” or a ceiling fan that might be “off, low, medium, medium-high, high"
  
 In XTension the enumerations are stored as a comma delimited string in the enumerated values field of the display tab in the edit unit dialog. They are also used as the values for the popup menu if that is selected as the default control type to present for the unit. In XTension the enumerations are stored as a comma delimited string in the enumerated values field of the display tab in the edit unit dialog. They are also used as the values for the popup menu if that is selected as the default control type to present for the unit.
Line 12: Line 17:
 end if end if
 </code> </code>
 +
 +
 +There is an optional parameter **for** which you can use to return the enumeration for a value other than the current value of the Unit.
 +
 +<code applescript>
 +write log “if the value was 2 then the enumeration would be “ & (enumerated value of “The Unit” for 2)
 +</code>
 +
 +this is particularly useful in the On and Off scripts of the Unit where you might wish to check the enumeration rather than the [[dictionary:unitinformation:futurevalue|future value]]. Since the actual dictionary value of the Unit is not changed until AFTER the On script runs you cannot simply call enumerated value of in the ON script to get the NEW value, it will return the current value. 
 +
 +So in order to get the enumerated value of the future value use the verb like this:
 +
 +<code applescript>
 +write log “after this script the enumeration will be “ & enumerated value of (thisUnit) for (future value)
 +</code>
 +
  
 ====History:==== ====History:====
   * the enumerated value of verb was added in XTension version 9.4.36   * the enumerated value of verb was added in XTension version 9.4.36
 +  * optional “for” parameter added in XTension version 9.5.3
dictionary/unitinformation/enumeratedvalue.txt · Last modified: 2023/05/20 15:14 by James Sentman