| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| twinkle 
 
 
 Joined: 31 Jan 2006
 Posts: 79
 
 
 | 
			
				|  Posted: Tue Jan 31, 2006 9:17 pm    Post subject: Pulling random entry from a file |   |  
				| 
 |  
				| I have a database of quotes and I want to pull a random entry from the database but I would like the random input to be seeded by user interaction, be it a single keystroke or even better a word. 
 Does anyone have any suggestions on how to implement this?
 _________________
 I shine
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| mikelbeck 
 
 
 Joined: 31 Jan 2006
 Posts: 18
 Location: Lawn Guyland, Noo Yawk
 
 | 
			
				|  Posted: Tue Jan 31, 2006 10:18 pm    Post subject: |   |  
				| 
 |  
				| What do you mean by "seeded by user action"? You want a user to enter something and then you pull a quote that matches? |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| paul 
 
 
 Joined: 11 Oct 2004
 Posts: 128
 
 
 | 
			
				|  Posted: Wed Feb 01, 2006 1:04 am    Post subject: |   |  
				| 
 |  
				| You can use the current time as a unique seed. I mean the time the user clicked... _________________
 World Countries | Survival Skills
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| twinkle 
 
 
 Joined: 31 Jan 2006
 Posts: 79
 
 
 | 
			
				|  Posted: Wed Feb 01, 2006 6:29 am    Post subject: |   |  
				| 
 |  
				|  	  | mikelbeck wrote: |  	  | What do you mean by "seeded by user action"? You want a user to enter something and then you pull a quote that matches? | 
 
 Paul mentions the time as a seed, and that would work, but I want the user to feel like they are having an impact on the randomness.  So I want to have them enter a short text string of whatever they want and use that to seed the random number that then pulls the entry from the database.
 
 I guess I could just lie to the user and use the time, but I would rather just have the value of the text work as the seed, if possible.
 _________________
 I shine
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| mikelbeck 
 
 
 Joined: 31 Jan 2006
 Posts: 18
 Location: Lawn Guyland, Noo Yawk
 
 | 
			
				|  Posted: Wed Feb 01, 2006 11:21 am    Post subject: |   |  
				| 
 |  
				| Say you have 100 records in your database, you could use the seconds from the time the user entered their information to pull a record. |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| twinkle 
 
 
 Joined: 31 Jan 2006
 Posts: 79
 
 
 | 
			
				|  Posted: Wed Feb 01, 2006 1:14 pm    Post subject: |   |  
				| 
 |  
				|  	  | mikelbeck wrote: |  	  | Say you have 100 records in your database, you could use the seconds from the time the user entered their information to pull a record. | 
 
 Hmm.. Okay I guess that would work.  Can I not just use the ascii value (or whatever) of the text and add it together or something?  Would that be possible.  I honestly do not know why I am going to all the trouble, nobody would actually know except for me, but I would feel better if it worked as I presented it.
 _________________
 I shine
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		|  |