| Author | 
		Message | 
	
		 
		pinkbob
 
 
 
    
		 | 
		
		
			
				  Posted: Fri Oct 19, 2007 4:37 pm    Post subject: How to get a number with spaces in between as a integer instead of a string  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				I tried 
 
var number : string := "123 309 358"
 
var value : int := strint(number)
 
 
but it doesn't work because there are spaces in between the string.
 
thanks. | 
			 
			
				 | 
			 
		  | 
	
	 
		 | 
		
		 | 
	
	
 
		  | 
	
		 
		Sponsor Sponsor 
		 
  
		 | 
		
 | 
	
	 
		  | 
	
				 
		HeavenAgain
 
  
 
    
		 | 
		
		
			
				  Posted: Fri Oct 19, 2007 5:04 pm    Post subject: RE:How to get a number with spaces in between as a integer instead of a string  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
					  | code: | 	 		  var numberString : string := "123 123 123"
 
var num : string := ""
 
var numbered : int
 
for i : 1 .. length (numberString)
 
    if numberString (i) not= " " then
 
        num += numberString (i)
 
    end if
 
end for
 
numbered := strint (num)
 
put numbered
 
  | 	  
 
 
  im sure theres better way than this | 
			 
			
				 | 
			 
		  | 
	
	 
		 | 
		
		 | 
	
	
 
		  | 
	
				 
		Clayton
 
  
 
    
		 | 
		
		
			
				  Posted: Fri Oct 19, 2007 5:12 pm    Post subject: RE:How to get a number with spaces in between as a integer instead of a string  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				There is! Make that a function that you can use over and over again  
 
 
	  | Turing: | 	 		  
function strip  (numberString  : string) : int
    var resultString  : string := ""
    for i  : 1 ..  length (numberString )
        if numberString  (i ) ~ = " " then
            resultString + = numberString  (i )
        end if
    end for
    if strintok (numberString ) then
        result strint (numberString )
    else
        result 0
    end if
end strip
   | 	 
  | 
			 
			
				 | 
			 
		  | 
	
	 
		 | 
		
		 | 
	
	
 
		  | 
	
				 
		pinkbob
 
 
 
    
		 | 
		
		
			
				  Posted: Fri Oct 19, 2007 5:15 pm    Post subject: RE:How to get a number with spaces in between as a integer instead of a string  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| thanks for the help, really appreciate it! | 
			 
			
				 | 
			 
		  | 
	
	 
		 | 
		
		 | 
	
	
 
		  | 
	
				 
		 |