Files Input/output 
	 
	
		| Author | 
		Message | 
	 
		 
		paulkwatyra
 
  
 
    
		 | 
		
		
			
				  Posted: Sat Jan 07, 2006 6:44 pm    Post subject: Files Input/output  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				ok so i have this code
 
 
[code]
 
var mmark, smark : real
 
var name : string
 
var stream, streamin : int
 
var total : real
 
loop
 
    open : streamin, "TEST.txt", get
 
    put "What is your name?"
 
    get name : *
 
    if name = "exit" then
 
        exit
 
    end if
 
    cls
 
    put "Hello: ", name
 
    put "What did you recieve in Math"
 
    get mmark
 
    cls
 
    put "What did you recieve in Science"
 
    get smark
 
    cls
 
    put "THANK YOU"
 
    total := (mmark + smark) div 2
 
    delay (1000)
 
    put "Your average is: ", total
 
    close : streamin
 
    delay (2000)
 
    open : stream, "TEST.txt", put
 
    put : stream, "STUDENT NAME: ", name
 
    put : stream, "AVERAGE FOR STUDENT: ", total
 
    close : stream
 
    cls
 
    put "Next Student Please :type exit to exit"
 
end loop
 
[/code]
 
---->NOTE<---- There needs to be a TEST.txt in the directory you saved this code int
 
 
however i cant get it to save multiple students in the directory TEST.txt how do you make it so that you can save lists of students into the directory. One more question is there anyway to create a new txt file from turing so that you dont need a TEST.txt to make it work?? | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
		 
		Sponsor Sponsor 
		 
  
		 | 
		
 | 
	 
	 
		  | 
	 
				 
		person
 
 
 
    
		 | 
		
		
			
				  Posted: Sat Jan 07, 2006 7:19 pm    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
					  | code: | 	 		  
 
var mmark, smark : real
 
var name : string
 
var stream, streamin : int
 
var total : real
 
open : stream, "TEST.txt", put
 
loop
 
    put "What is your name?"
 
    get name : *
 
    if name = "exit" then
 
        exit
 
    end if
 
    cls
 
    put "Hello: ", name
 
    put "What did you recieve in Math"
 
    get mmark
 
    cls
 
    put "What did you recieve in Science"
 
    get smark
 
    cls
 
    put "THANK YOU"
 
    total := (mmark + smark) div 2
 
    delay (1000)
 
    put "Your average is: ", total
 
    delay (2000)
 
    put : stream, "STUDENT NAME: ", name
 
    put : stream, "AVERAGE FOR STUDENT: ", total
 
    cls
 
    put "Next Student Please :type exit to exit"
 
end loop
 
  | 	  
 
 
i really didnt understand y u needed to have streamin | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		paulkwatyra
 
  
 
    
		 | 
		
		
			
				  Posted: Sat Jan 07, 2006 7:47 pm    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| sry extra var | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		paulkwatyra
 
  
 
    
		 | 
		
		
			
				  Posted: Sun Jan 08, 2006 5:41 pm    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| NEONE GOIN TO HELP OR WUT | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		iker
 
  
 
    
		 | 
		
		
			
				  Posted: Sun Jan 08, 2006 6:23 pm    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				paulkwatyra wrote: NEONE GOIN TO HELP OR WUT 
 
probly not if your asking like that. Try searching close, get, put, read, write, seek and tell statements. in the help file, it will tell you all about that, or try [/url=http://www.compsci.ca/v2/search.php]SEARCHING[/url] this website older topics about what you are asking... isn't that what we are supposed to do? | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		MysticVegeta
 
  
 
    
		 | 
		
		
			
				  Posted: Sun Jan 08, 2006 7:54 pm    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| When you close the stream # you close the file so in order to write again to that file you dont close the stream # until the user exits the loop. So Instead of having close : stream in the loop, put it after. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		 | 
	 
 
	
	
	 
	
	 |