Posted 27 July 2012 - 01:44 PM
So I've been working on a program that allows a user to send news from a remote console to update a large monitor display in the town hall of a town I live near in a particular server. With the help of several forummers here, I've managed to resolve all of the coding issues I was experiencing during this process. There is, however, one question that remains in my mind.
The setup that I'm using uses three computers and a disk drive. The remote console sending the news updates sends messages over rednet to a second computer, which is in a while true do loop to listen for messages. The listener computer then writes these messages to a blank file on a floppy disk in an adjacent disk drive, and the third computer, also adjacent to the disk drive, then grabs info from that file to display on the monitor. The program works wonderfully, and I'm quite pleased.
However, I've noticed that every time I open the file in which the data is stored (henceforth referred to as /disk/logs), after saving and exiting, it adds a blank space to the bottom of the file. For example, if the contents of the file were as follows:
And I opened it up manually because the # was a typo and should be a 3, then saved it and promptly sent a new news update, "Test 4" from the remote console and then "Test 5" immediately thereafter, it would look like this:
And if I opened it up manually and deleted that annoying blank line and repeated the process, we'd have:
Now, code-wise, I worked around this by having the program in the third computer ignore lines equal to "" when grabbing the file contents, but I'm curious as to whether or not anyone knows why this is, and if there is a way to prevent it.
The setup that I'm using uses three computers and a disk drive. The remote console sending the news updates sends messages over rednet to a second computer, which is in a while true do loop to listen for messages. The listener computer then writes these messages to a blank file on a floppy disk in an adjacent disk drive, and the third computer, also adjacent to the disk drive, then grabs info from that file to display on the monitor. The program works wonderfully, and I'm quite pleased.
However, I've noticed that every time I open the file in which the data is stored (henceforth referred to as /disk/logs), after saving and exiting, it adds a blank space to the bottom of the file. For example, if the contents of the file were as follows:
Test 1
Test 2
Test #
And I opened it up manually because the # was a typo and should be a 3, then saved it and promptly sent a new news update, "Test 4" from the remote console and then "Test 5" immediately thereafter, it would look like this:
Test 1
Test 2
Test 3
Test 4
Test 5
And if I opened it up manually and deleted that annoying blank line and repeated the process, we'd have:
Test 1
Test 2
Test 3
Test 4
Test 5
Test 6
Test 7
Now, code-wise, I worked around this by having the program in the third computer ignore lines equal to "" when grabbing the file contents, but I'm curious as to whether or not anyone knows why this is, and if there is a way to prevent it.