90 of 318
ZBasic System Library 80 ZX Microcontroller Family Delay Type Subroutine Invocation Delay(time) Parameter Method Type Description time ByVal Single The amount of time to delay, in seconds. Discussion This routine suspends the current task for a period of time at least as long as specified. The actual delay depends on what other tasks actually do that may run in the interim. It is possible that the task will be suspended indefinitely depending on what another task might do. Note that if the current task is locked, this call will unlock it. There is a subtle difference between Delay() and Sleep() when the arguments are non-zero. For Delay() the specified time is the minimum amount of delay that the task will experience assuming that no other task is ready to run. The actual delay could be up to 1.95ms longer than the specified delay. For Sleep(), the specified time is the maximum amount of delay that the task will experience assuming that no other task is ready to run. The actual delay could be up to 1.95ms less than the specified delay. Example Do Call PutPin(25, 0) Call Delay(0.5) Call PutPin(25, 1) Call Delay(0.5) Loop This loop causes the red LED to turn on an off alternately for a half second each. Compatibility The BasicX documentation specifically indicates that Delay() will unlock a locked task. However, tests indicate that this only happens if the parameter to Delay() is non-zero. This implementation unlocks a task on any Delay() call. See Also DelayUntilClockTick, Pause, Sleep, Register.RTCStopWatch