Please note that the recommended version of Scilab is 2023.1.0. This page might be outdated.
See the recommended documentation of this function
suspend all code executions (console, scripts, callbacks,..)
sleep(milliseconds) sleep(seconds, "s")
- duration of the sleep, in milliseconds (decimal number)
- duration of the sleep, in seconds (decimal number)
sleep stops Scilab processing any instruction for
a specified number of milliseconds or seconds:
- input and output in console are suspended.
The CTRL-C interruption is caught but performed only at the end of the sleep.
- Scripts and functions:
sleep(..)is called inside a script or a function, Scilab waits for the given duration before processing the next instruction. CTRL-C in the console is caught but performed only at the end of the sleep.
- .. are actions triggered by interactions
with menus and with
uicontrolinteractive graphical components. During the sleep(..), these interactions are caught, and related instructions are buffered. Buffered actions are all performed after sleep()'s end.
- Graphics interactions:
sleep(..)does not prevent interacting with graphics, providing that the interaction mode has been turned on before entering the sleep. Then, moving curves, editing graphics labels, etc is still possible during Scilab's sleep. The wake-up does not reset these actions.
Time resolution is not.. time accuracy: The actual suspension time may be longer than the specified one, due to other processes run in the system, or due to the time spent to process the call.
// Simple examples tic; sleep(4350); toc tic; sleep(4.35, "s"); toc // Testing the sleep's accuracy: results = ; disp("Please wait... sleep()s and wake-up are performed...") for i = -1:4 dt = 10^i; // specified duration [ms] tic; sleep(dt); dta = toc()*1000; // actual duration [ms] results = [results ; dt dta ]; end results // Test of the CTRL-C interruption: disp("Press CTRL + C keys now: the 15 s sleep is going on") sleep(15,"s") // Test of interactions with menus: clf plot2d() // [If you are a MacOS user, select the menu "Edit=> Clear figure" instead] mprintf("During this 30s sleep, click on the figure\n then on its menu ""Edit => Figure properties""") // The graphical editor will be actually called only at wake-up sleep(30, "s")
|Report an issue|
|<< realtimeinit||Time and Date||tic >>|