How to pause a script for a given time

From Scriptwiki
Revision as of 13:02, 7 July 2007 by Cail (talk | contribs) (added category)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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 
}