Posts: 992
	Threads: 74
	Joined: Jan 2010
	
	
 
	
	
		If I have a txt file called "Text" in my games data folder.
The content of this txt file is:
print "hi"
How can I execute this text file from an in-editor script?
	
	
	
	
	
 
 
	
	
	
		
	Posts: 1,115
	Threads: 41
	Joined: May 2009
	
	
 
	
	
		Try
Code:
file = File.open("Text", "rb")
file.each_line {|line|
  eval(line)
}
file.close
 
 
	
	
	
		
	Posts: 992
	Threads: 74
	Joined: Jan 2010
	
	
 
	
	
		Thanks a lot. It works ^^
EDIT:
when i have a whole class with lots of stuff in the txt document, I get the following error:
Syntax error occurred while running script
	
	
	
	
	
 
 
	
	
	
		
	Posts: 50
	Threads: 19
	Joined: Sep 2009
	
	
 
	
	
		That's simple, you have syntax error in the text file. Try copying the script from the text file to the RMXP scripts and run the game, then RMXP will tell you where the syntax error is.
	
	
	
	
	
 
 
	
	
	
		
	Posts: 992
	Threads: 74
	Joined: Jan 2010
	
	
 
	
	
		I tried, but I don't get any errors.
So, what I'm trying to do is to have the Scene_Title class in a txt document and load it into the game using the code charlie provided.
	
	
	
	
	
 
 
	
	
	
		
	Posts: 50
	Threads: 19
	Joined: Sep 2009
	
	
 
	
	
		Try with this code insteand:
Code:
file = File.open("Text", "rb")
eval(file.readlines)
file.close
 
 
	
	
	
		
	Posts: 992
	Threads: 74
	Joined: Jan 2010
	
	
 
	
	
		I'm closer now.
but It gives me the following error:
line 4: cannot convert array into string
	
	
	
	
	
 
 
	
	
	
		
	Posts: 50
	Threads: 19
	Joined: Sep 2009
	
	
 
	
	
		Ohh, sorry, I forget a bit of code:
Code:
file = File.open("Text", "rb")
eval(file.readlines.join)
file.close
 
 
	
	
	
		
	Posts: 992
	Threads: 74
	Joined: Jan 2010
	
	
 
	
	
		Thank you very much. You have been of great support ^^