Home » Community » Newbie corner » Stopping ReadStdIn() function  
	
		
		
			| Re: Stopping ReadStdIn() function [message #57045 is a reply to message #57043] | 
			Mon, 17 May 2021 18:24   | 
		 
		
			
				
				
				  | 
					
						  
						Xemuth
						 Messages: 387 Registered: August 2018  Location: France
						
					 | 
					Senior Member  | 
					 | 
		 
		 
	 | 
 
	
		Hello again Oblivion, I like the tiemout approach. here is what I did : 
String ReadCmd(int timeout)
{
	String r;
	int time = msecs();
	
	while(msecs(time) < timeout){
		int c = 0;
		int n = read(STDIN_FILENO, (char*) &c, 1);
		if(c == '\n')
			break;
		if(n > 0) {
			r.Cat(c);
			time = msecs();
		}
	}
	return r.GetCount() ? r : String::GetVoid();
}
 
It now work perfectly. Thanks for your precious help ! 
		
		
		[Updated on: Mon, 17 May 2021 18:29] Report message to a moderator  
 |  
	| 
		
	 | 
 
 
 |  
  
 
Goto Forum:
 
 Current Time: Tue Nov 04 10:02:27 CET 2025 
 Total time taken to generate the page: 0.03558 seconds 
 |