PennController for IBEX › Forums › Support › Displaying n words on screen › Reply To: Displaying n words on screen
May 15, 2023 at 9:59 am
#10594
Keymaster
You could test the value of the Var element right after you increment it in the callback to see if the updated index goes beyond the number of words, and if so, wait for a key press on K to stop the timer:
newKey("NEXT", " ")
.callback(
getVar("nextWordStartsAt").test.is(v=>v<row.Words.split('_').length).success(
getVar("listOfWords")
.set(getVar("nextWordStartsAt"))
.set(v=>row.Words.split('_').slice(v,v+10).join("<br>"))
,
getText("words").text( getVar("listOfWords") )
,
getVar("nextWordStartsAt")
.set(v=>v+10) // update the index
.test.is(v=>v>=row.Words.split('_').length).success( // if the index is greater than the # of words
newKey("K").wait() // wait for a key press on K
,
getTimer("recording").stop() // stop the timer
)
)
)
Jeremy