245 of 307
ZBasic System Library 235 ZX Microcontroller Family SetInterval Type Subroutine Invocation SetInterval(interval) Parameter Method Type Description interval ByVal Single or int16 The interval counter period, in RTC ticks (if an integral value is specified) or seconds (if a Single value is given). Discussion This routine sets the period of the built-in interval counter. On each RTC tick, the interval counter will be decremented. When it gets to zero, it is reloaded with the specified value and it begins to count down again. Furthermore, if a task is awaiting the interval expiration, it is immediately scheduled for execution (unless a higher priority task requires service). If no task is awaiting the interval expiration, the fact that the interval counter expired is recorded. Subsequently, a task may request a wait on the interval and, depending on the nature of the request, the task may be immediately triggered or it may await the next interval expiration. Internally the interval period is stored as a 16-bit unsigned integer value. This limits the interval period to a maximum of slightly less than 128 seconds. Of course, longer interval periods may be effectively implemented by maintaining a counter and taking action after the expiration of a number interval periods. Example Call SetInterval(200) 'about 391 milliseconds Call SetInterval(10.0) 'about 10 seconds Compatibility This routine is not available in BasicX compatibility mode. See Also WaitForInterval