Skip to content

Commit

Permalink
Clean up pause and sleep functions
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Jan 14, 2017
1 parent 4408209 commit e7e9592
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
11 changes: 6 additions & 5 deletions octave_kernel/@pause/pause.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@

function pause(n)
if (nargin == 0)
disp('** Pausing execution indefinitely. Interrupt the kernel to continue'
);
builtin('pause');
input('Paused, enter any value to continue');
elseif (n > 5)
msg = sprintf('** Pausing execution for %0.1f seconds. Interrupt the kernel to abort pause.', n);
disp(msg);
msg = '** Pausing execution for %0.1f seconds.';
if (!ispc())
msg = strcat(msg, ' Interrupt the kernel to abort pause.');
end;
disp(sprintf(msg, n))
builtin('pause', n);
else
builtin('pause', n)
Expand Down
7 changes: 5 additions & 2 deletions octave_kernel/@sleep/sleep.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
function sleep(varargin)
seconds = varargin{1};
if (seconds > 5)
msg = sprintf('** Sleeping for %0.1f seconds. Interrupt the kernel to abort sleep.', seconds);
disp(msg);
msg = '** Sleeping for %0.1f seconds.';
if (!ispc())
msg = strcat(msg, ' Interrupt the kernel to abort sleep.');
end
disp(sprintf(msg, seconds));
end
builtin('sleep', seconds);
endfunction
7 changes: 5 additions & 2 deletions octave_kernel/@usleep/usleep.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
function usleep(varargin)
usec = varargin{1};
if (usec > 5e6)
msg = sprintf('** Sleeping for %0.1f seconds. Interrupt the kernel to abort sleep.', usec / 1e6);
disp(msg);
msg = '** Sleeping for %0.1f seconds.';
if (!ispc())
msg = strcat(msg, ' Interrupt the kernel to abort sleep.');
end
disp(sprintf(msg, usec / 1e6));
end
builtin('usleep', usec);
endfunction

0 comments on commit e7e9592

Please sign in to comment.