Scilab Home page | Wiki | Bug tracker | Forge | Mailing list archives | ATOMS | File exchange
Please login or create an account
Change language to: English - Français - Português - 日本語 -
Справка Scilab >> Time and Date > sleep

sleep

suspend all code executions (console, scripts, callbacks,..)

Syntax

sleep(milliseconds)
sleep(seconds, "s")

Arguments

milliseconds
duration of the sleep, in milliseconds (decimal number)
seconds
duration of the sleep, in seconds (decimal number)

Description

sleep stops Scilab processing any instruction for a specified number of miliseconds or seconds:

Console:
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:
When 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.
callbacks:
.. are actions triggered by interactions with menus and with uicontrol interactive 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:
  • Windows systems: 0.5 ms
  • Linux systems: 1 µs
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.

Examples

// 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")

See also

  • pause — режим паузы, вызов клавиатуры
  • halt — stop execution

History

ВерсияОписание
6.0
  • The fractional part of milliseconds is now accepted and processed (replace xpause(microseconds)).
  • Syntax sleep(seconds, "s") added.
Scilab Enterprises
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Feb 14 15:13:26 CET 2017