Hello
Guest
it is
May 23, 2024, 12:57:25 PM
Guest
Login
Register
Menu
Home
Help
Search
Calendar
Members
Members
View the memberlist
Search For Members
Login
Register
YouTube
Machsupport Forum
/
Mach Discussion
/
Mach4 General Discussion
/
Lua file operations
« previous
next »
Print
Pages:
1
Go Down
Author
Topic: Lua file operations (Read 1852 times)
0 Members and 1 Guest are viewing this topic.
thespindoctor
307
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
Logged
joeaverage
7,575
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
Logged
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
thespindoctor
307
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...
Logged
thespindoctor
307
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
Logged
thespindoctor
307
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.
Logged
joeaverage
7,575
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
Logged
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
thespindoctor
307
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!
Logged
Cbyrdtopper
910
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.
Logged
Chad Byrd
thespindoctor
307
Re: Lua file operations
«
Reply #8 on:
April 26, 2018, 11:06:41 AM »
Just a simple one line write to a file!
Logged
Print
Pages:
1
Go Up
« previous
next »