Raise a signal

signal name
(signal name arg)
signalw name
(signalw name arg)

Raises a signal with the name and optionally with the attached parameter arg. The signal instruction is not blocking and the calling program continues while the signalw is blocking and the calling program is waiting for completion of all handling functions triggered by the signal (note: turtle cannot send the blocking signal to itself).

Example 1:

to model
  to onsignaltest
    print who
  end
end

"t := newturtles 3 $model
signal "test
print "sent

Output:
Program of the signal sender runs in parallel to the execution of handling functions. The order of text outputs can differ in each execution.

sent
model1
model3
model2

Example 2:

to model
  to onsignaltest
    print who
  end
end

"t := newturtles 3 $model
signalw "test
print "handled

Output:
Program of the signal sender is waiting until the handling functions are finished. The order of "modelx" text outputs can differ, but the "handled" message appears always at the end.

model2
model1
model3
handled

See also:

Turtle - object

Table of Content