Data Sheet
dScript
dScript User Manual v2.15
Thread commands.
thread, threadstart, threadsleep, threadsuspend
thread <name> <trigger option>
This is used to declare a thread, it is followed by the name of the thread. The name is also the
starting point for your thread and so must also be declared as a label in your program. Trigger
option selects a way to automatically run the thread, the options are:
thread myFirstThread const
This thread is a constantly running thread and has no trigger options, if it suspends itself with
threadsuspend then it will not run again unless re-started by another thread.
thread myFirstTimer 500
When a number is used as the trigger option, it is a time in mS. There are 1000mS in one
second, so this example runs every 500mS or half second. The thread should have completed
its task and have suspended itself with threadsuspend before the trigger event comes around
again.
thread myTcpipCmd tcpip
This thread will be triggered when an incoming tcpip packet arrives.
thread myInterrupt1 input 9
Threads may be triggered when an input changes state. This example is triggered when the
input becomes active.
thread myInterrupt2 !input 10
Putting a ! before the input will cause the thread to be triggered when the input goes inactive.
thread myInterrupt3 ^input 11
A thread may be triggered on both active and inactive transitions by putting a ^ before the
input.
thread pulseOutput myVar
This thread will be triggered when myVar becomes non-zero, The variable myVar must have
been previously declared. myVar must be reset to zero before the thread ends or it will
immediately re-trigger.
threadstart <name>
This is used to start a thread. Threads are created in a stopped state (not a suspended state)
and will not run until the threadstart command is issued. Note that threadstart will not actually
start the thread unless it is declared as a const thread. For all other threads it "arms" the
thread so that it will run on its next trigger event.
threadstart myFirstThread
This will arm the thread and make it ready to run. A const thread will start immediately. All
others will be armed and will run when their trigger event ocours.
Copyright © 2016, Devantech Ltd.
All rights reserved.
www.robot-electronics.co.uk
53