Hello Guest it is March 28, 2024, 10:07:13 AM

Author Topic: Lua file operations  (Read 1718 times)

0 Members and 1 Guest are viewing this topic.

Lua file operations
« on: April 25, 2018, 05:23:01 PM »
I cannot get Lua to write to an empty file.  I create the file nicely and if I put a character on the first line then the write command works fine
If I create a file which is empty, then the commands do not work.

Anyone have this problem?

THanks
Re: Lua file operations
« Reply #1 on: April 25, 2018, 06:23:29 PM »
Hi,
I think you have to open the file, then flush() and then close() before the file will stick even though
its empty.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Lua file operations
« Reply #2 on: April 25, 2018, 07:45:48 PM »
That is whatI am doing but the strange thing is it works only when there is at least one character on rhe first line.

I have tried all kinds of manipulations.  Everything works as expected with a file that is not empty.

Nothing works on an empty file...
Re: Lua file operations
« Reply #3 on: April 25, 2018, 07:47:50 PM »
Could be an issue since i first open the file to read it then check to find a zero length.  Then close it and reopen it for writing
Re: Lua file operations
« Reply #4 on: April 25, 2018, 09:17:04 PM »
Working now.  I just simplified the variables and it is working.  I had been saving the file name from a variable into an easier variable. Leaving it in the first variable worked.
Re: Lua file operations
« Reply #5 on: April 26, 2018, 12:37:26 AM »
Hi,
maybe a file has to have one character...an EOF character?

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Lua file operations
« Reply #6 on: April 26, 2018, 09:37:27 AM »
No it works fine now.  I had another script running that created a global variable for path and file but then I stored that file name in a local variable.  This caused the issue.  When I use the global variable, it works fine!
Re: Lua file operations
« Reply #7 on: April 26, 2018, 10:42:10 AM »
What exactly are you trying to do here?  Write to a file?
You've struck my curiosity haha.
Chad Byrd
Re: Lua file operations
« Reply #8 on: April 26, 2018, 11:06:41 AM »
Just a simple one line write to a file!