Anonymous user
Events: Difference between revisions
m
→{{header|REXX}}: added/changed comments and whitespace, changed indentations.
m (→{{header|REXX}}: added/changed comments and whitespace, changed indentations.) |
|||
Line 772:
=={{header|REXX}}==
Although REXX can be event driven, most events would probably have to be actively checked to see if the event occurs.
<br>Here is a ''time-driven'' example of events happening, based on specific timer ticks.
<lang rexx>/*REXX program
signal on halt /*allow the user to HALT the
parse arg timeEvent /*allow the "event" to be specified. */
if timeEvent='' then timeEvent=5 /*
event?: do forever /*determine if an event has occurred. */
theEvent=right(time(),1) /*maybe it's an event, ─or─ maybe not.*/
if pos(theEvent,timeEvent)\==0 then signal happening
end /*forever*/
say 'Control should never get here!' /*This is a logic
halt: say '════════════ program halted.'; exit
/*──────────────────────────────────────────────────────────────────────────────────────*/
happening:
do while theEvent==right(time(),1)
end /*while*/ /*NOP is a special REXX statement. */
'''output''' when using the input of: <tt> 1 3 5 0 7 9 </tt>▼
signal event? /*see if another event has happened. */</lang>
▲'''output''' when using the input of: <tt> 1 3 5 0 7 9 </tt>
<pre>
an event occurred at 16:13:29, the event is: 9
Line 807 ⟶ 809:
an event occurred at 16:13:51, the event is: 1
an event occurred at 16:13:53, the event is: 3
════════════ program halted.
</pre>
|