... Software for the people!
Become a member of Tropical Technologies Community, right now!
Search
Main Menu
Login
Username:

Password:

remember me

Lost Password?

Register now!
Recent Downloads
Shell Object Edito...
(Software, Mon, 18-May-2009)
TimeCube
(Software, Sat, 15-Nov-2008)
SciTE 1.76 plus Sh...
(Software, Sat, 05-Apr-2008)
Hotkey Plugin SDK
(QCD Plugins, Sun, 29-Oct-2006)
Hotkey Plugin
(QCD Plugins, Sun, 29-Oct-2006)
Transparent Image
(Samurize, Sat, 13-May-2006)
Lua Script (beta 6...
(Samurize, Fri, 03-Mar-2006)
Samurize Universal...
(Samurize, Tue, 24-Jan-2006)
Line Input Plugin
(QCD Plugins, Sun, 08-Jan-2006)
Custom Progress
(Samurize, Sun, 13-Mar-2005)
Reading the contents of a text file
Submitter: Tropics Date: 2006/2/23 22:35 Views: 183
Summary: This article describes how to read the contents of a text file - both raw (line by line) and xml-formatted.
Keywords: text xml file read

Reading a raw text file
This extremely simple script displays the contents of a text file. This is only to demonstrate how to read a file.

main script (no init script needed)
buffer = ""

-- read news.xml
for line in io.lines("c:\\samurize\\news.xml") do buffer = buffer .. line end

return buffer


The script does not test if the file is there ... it really should be. All it does is read all the file contents into the variable "buffer" and return it. Of course you can do everything with the buffer you want.

As noted, leave the init script field empty. The "IO Library" box has to be checked in the options dialog, it contains the file functions.
Pages: (1) 2 »
URL: http://www.tropictech.de/modules/article/view.article.php?c1/10
Rate
10987654321