User Tools

Site Tools


Sidebar

dictionary:more:dolater

Table of Contents

Do Later

Execute a handler in the same script in some number of milliseconds. It’s often necessary to add in a “delay” to some scripts when talking to other devices or programs, unfortunately a delay causes the entire program to block until the delay is complete. This is not acceptable for an application that must remain responsive to other input while that script is running. do later lets you schedule handlers in a script to happen one after another as if the script was written entirely inline but with delay statements while avoiding the problems of blocking the entire app for extended periods of time.

Usage:

do later [text] the name of the handler to do later. This will always be in the same script, you cannot do later into a different script. This works for Global Script, unit ON or OFF scripts or Interface scripts.

in [integer] the number of milliseconds to call the handler specified in the default parameter. A second is 1000 milliseconds so if you wanted to run the named handler in 4 seconds you would specify 4000.

with data [any or list of any: optional] if you have information you wish to pass on to the handler you can specify it here. Passing {“one”, “two”} would pass those into a handler written as: on myHandler( paramOne, paramTwo) where paramOne would be “one” and so forth.

Examples:

  write log “the script has started"
  do later “partTwo” in 3000
  
  on partTwo()
    write log “part two is being run!"
    do later “partThree” in 5000 with data {“my info is here”}
  end partTwo
  
  on partThree( theInfo)
    write log “part three is running with passed data “ & theInfo
  end partThree

Notes:

  • Added to XTension in version 9.3 on 6/2/2017
  • Only one “do later” delay can be running in a specific script at a time. If something happens and the chain of callbacks is started over the new call to do later will stop any sequence already in progress.
dictionary/more/dolater.txt · Last modified: 2017/06/02 21:03 (external edit)