View Full Version : appending to a file (text file creation) - LUA
AlCapone
April 10th, 2004, 12:43 PM
I am trying to use Girder to create a HTML file - so all I am looking for is a way to open, add text, and close a file.
I would like to use LUA
(as opposite to dumping to file thru a bat file & argumnets)
But the poor LUA documentation does not make it easier...
anyone see bugs ? - (sure you do) :)
h = openfile ("c:\a.txt","w")
writeto ("c:\a.txt")
write (h,"test")
closefile h
I tried writing first, but no luck, the goal is to append text
AlCapone
April 10th, 2004, 12:52 PM
were looking for a "print to file" function, but lo luck...
I am still amazed how such a great program (LUA) can be that poorly documented...
BeRnA
April 10th, 2004, 01:44 PM
fd = openfile ("c:\\a.txt","a")
write (fd,"new line")
closefile(fd)
So simple as that...
Promixis
April 10th, 2004, 01:51 PM
For more options, I would suggest using the FileSystemObject.
See the luacom thread.
AlCapone
April 10th, 2004, 02:34 PM
thank you
thank you
Promixis
April 10th, 2004, 03:34 PM
were looking for a "print to file" function, but lo luck...
I am still amazed how such a great program (LUA) can be that poorly documented...
Get the Lua book from amazon. It covers lua 5 but is mostly compatible with lua 4.
AlCapone
April 10th, 2004, 11:57 PM
Get the Lua book from amazon. It covers lua 5 but is mostly compatible with lua 4.
I will try to find out what's inside them...
I still remember six books I bought many years ago, the goal were to get more advanced asssembly knowledge....., some books were for newbies, other mainly about making use of certain linkers/compilers, rather than FPU instructions.
and the one about speed, discussed Turbo Profiler while I was looking for raw information about optimizations... , not "how to use turbo profiler" - because I did not use TASM at that time..
- bit afraid of LUA book being full of incomplete, theoretical examples like
http://lua-users.org/wiki/FileInputOutput , or too basic..
Promixis
April 11th, 2004, 04:06 AM
I have read the first 6 or so chapters and found it be very useful and interesting. I haven't spent anytime reading about file io
AlCapone
April 11th, 2004, 11:42 AM
not asking you to read the book for me, just let out som steam, after putting your good help to use, I got stuck 1 minute later :)
tried to make a new line CR/LF , writing to file chr(10) and chr(13)
tried :
write (fd, string.char(10,13))
according to : http://lua-users.org/wiki/StringsTutorial
but no
tried:
fedup = string.char(10,13)
write (fd, fedup)
but nooooo :)
even string.char does not work....
- I also tried "/n" in pure desperation :)
the paranoia says this language is made up just to annoy me ....
:)
Promixis
April 11th, 2004, 12:17 PM
I think you are using lua 5 and not lua 4 code...
lua 4 doesn't uses a different string library.
AlCapone
April 11th, 2004, 01:17 PM
thanks - I suspected that ... thanks to the brilliant documentation it's not easy to know what version it's about...
BTW: does anybody know why Girder uses "old" LUA ? - is there any plan to implement ver 5 ?
>> the Lua book from amazon. It covers lua 5 but is mostly compatible with lua 4.
err... yes.... I see .. some guessing will be left to me - just like it is now :)
Powered by vBulletin® Version 4.1.8 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.