  | 
	
	
	
		Gatsby Novice
 
  Joined: 19 Dec 2006 Posts: 31
 
  | 
		
		  
			
			   Posted: Fri Jan 12, 2007 9:58 pm   
  Randomised #ALARM question   | 
			 
			
				Greetings,
 
 
I'm trying to make an alarm which doesnt really fire every exactly x seconds, but every randomised amount of seconds.
 
 
So, what I'd like to do is 
 
 
#AL %random(5,10) {<commands>}
 
 
However I dont think this works.
 
 
with #EXEC %concat ....   I think I could setup an alarm for a randomised amount of time, but it would fire at exactly that time each time.
 
 
So I suppose I need a one-shot alarm which finishes by setting up the next one-shot alarm etc
 
 
Problem is I have no clue on how to do it
 
 
Someone can help me?
 
 
TIA
 
Gats | 
			 
		  | 
	
	
	  | 
		  
		 | 
	
	
		  | 
	
	
		MattLofton GURU
 
  Joined: 23 Dec 2000 Posts: 4834 Location: USA
  | 
		
		  
			
			   Posted: Fri Jan 12, 2007 10:57 pm      | 
			 
			
				#alarm *@varname {varname = %random(x,y);#say Time: %time()}
 
 
You will notice a little bit of funkiness when you try to go look at the alarm, but it works. | 
			 
		  | 
	
	
	  
		  
		    
			  _________________ EDIT: I didn't like my old signature | 
			       | 
			 
		   
		 | 
	
	
		  | 
	
	
		Fang Xianfu GURU
  
  Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
  | 
		
		  
			
			   Posted: Fri Jan 12, 2007 10:58 pm      | 
			 
			
				Yes, that'll set alarm to a random time when it's created, not every time it fires. The easy way to do this is to use the %alarm function to change the timing of the alarm:
 
 
#alarm "TestAlarm" %random(5,10) {do whatever;#noop %alarm(TestAlarm,%eval(%random(5,10)*1000))}
 
 
should work - if it doesn't, set another alarm to change the first alarm's time 0.5 secs after it fires. | 
			 
		  | 
	
	
	  | 
		  
		 | 
	
	
		  | 
	
	
		Gatsby Novice
 
  Joined: 19 Dec 2006 Posts: 31
 
  | 
		
		  
			
			   Posted: Fri Jan 19, 2007 12:57 pm      | 
			 
			
				Hi Guys,
 
 
Had a little play with this and the easiest I found is :
 
 
#ALIAS repeatit {
 
  delay=%random(10,20)
 
  <do whatever you need doing>
 
  #IF (@repeating) {#ALARM +@delay {repeatit}}}
 
 
nm eventual syntax errors, am at the office where I dont have zmud installed, but it works fine at home.
 
 
repeating is a boolean that can be unset to stop the cycling
 
 
This looks like an infinite loop, but fortunately isn't.
 
 
Cheers,
 
Gats | 
			 
		  | 
	
	
	  | 
		  
		 | 
	
	
		  | 
	
	
		| 
		
		 | 
	
	
		 |