On the 2nd to last line 'String sData = {DescList(index)} " will not work without the braces. It sends an error:
or
error groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.call() is applicable for argument types: (java.lang.Integer) values: [1] Possible solutions: tail(), tail(), take(int), take(int), wait(), last() on line 43 (method handlerButton)
/* List Test App*/
import groovy.transform.Field
definition(
name: "List Test App", namespace: "hubitat", author: "JohnRob",
description: "test some code", category: "Convenience", iconUrl: "", iconX2Url: "")
preferences {
page(name: "mainPage")
}
def mainPage() {
dynamicPage(name: "mainPage", title: " ", install: true, uninstall: true) {
section {
input "thisName", "text", title: "Name this test", submitOnChange: true
if(thisName) app.updateLabel("$thisName")
input "testButton", "capability.pushableButton",title: "Button Driver", submitOnChange: true, required: true, multiple: false
} // section
} // dymanicPage
} // mainPage
@Field static List<String> DescList = ['Outside Temp = ', 'Outside Humidity = ']
def installed() {
initialize()
}
def updated() {
unsubscribe()
initialize()
}
def initialize() {
subscribe(testButton, "pushed", handlerButton)
}
def handlerButton(evt) {
int index = 1
log.info "DescList index1: ${DescList[index]}"
String sData = {DescList(index)} // why are the {braces} needed aroung DescList(index)
log.info "sData: ${DescList[index]}"
}
// --- eof ---