Difference between revisions of "How to pause a script for a given time"

From Scriptwiki
Jump to: navigation, search
(sleep alias)
 
m (removed that -l)
Line 3: Line 3:
 
server and user raws are processed and events pass. <br />
 
server and user raws are processed and events pass. <br />
  
  alias -l sleep {  
+
  alias sleep {  
 
   ;; when called as an identifier or the number of miliseconds  
 
   ;; when called as an identifier or the number of miliseconds  
 
   ;; to sleep is 0, return  
 
   ;; to sleep is 0, return  

Revision as of 14:00, 7 July 2007

Syntax: /sleep N
Causes a script to 'sleep' N miliseconds. During this time
server and user raws are processed and events pass.

alias sleep { 
  ;; when called as an identifier or the number of miliseconds 
  ;; to sleep is 0, return 
  if ($isid) || ($0 != 1) || ($1 !isnum) || ($1 < 1) !return 

  ;; otherwise set a unique filename to a var, write the remote script to 
  ;; that file and execute it using COM objects. 
  !var %f = $ticks $+ .wsf 
  !write %f <job id="js"><script language="jscript">WScript.Sleep( $+ $1 $+ );</script></job> 
  !.comopen %f WScript.Shell 
  if (!$comerr) .comclose %f $com(%f,Run,3,bstr,%f,uint,0,bool,true) 
  !.remove %f 
}