list of strings?
#21
Posted 29 March 2015 - 11:49 PM
#22
Posted 30 March 2015 - 12:48 AM
#23
Posted 30 March 2015 - 07:45 PM
Bomb Bloke, on 30 March 2015 - 12:48 AM, said:
Enderlist is only said in line 3, 7, and 10. in line 3 it's used as file.fsopen, in line 7 it's used as file.fsopen again, then line 10 is print(textutils.serialize(enderList). Nowhere in the code can i find where Enderlist is created as a variable, unless line 10 creates a variable. If it does, what can i do to fix that?
Edited by YUGATUG, 30 March 2015 - 09:06 PM.
#24
Posted 30 March 2015 - 09:38 PM
#25
Posted 30 March 2015 - 10:39 PM
#26
Posted 31 March 2015 - 06:07 AM
Geforce Fan's example served to show you how you might take a table - which is basically an organised collection of variables, ideal for storing eg multiple lines of text (and many other things!) - and write it to your HDD, and he followed that with an example of how you would then load the content of the resulting file back into a table in RAM. They were two separate examples of different tasks. Doing them one after the other doesn't allow you to magically "print your file".
Perhaps try reading through this tutorial directory, top to bottom. By the time you've covered the one about scope (no, I'm not saying skip ahead to that one - go top to bottom!), you should have the info you need to start coding your project.
#27
Posted 31 March 2015 - 07:20 PM
#28
Posted 31 March 2015 - 11:27 PM
Bomb Bloke, on 31 March 2015 - 06:07 AM, said:
Geforce Fan's example served to show you how you might take a table - which is basically an organised collection of variables, ideal for storing eg multiple lines of text (and many other things!) - and write it to your HDD, and he followed that with an example of how you would then load the content of the resulting file back into a table in RAM. They were two separate examples of different tasks. Doing them one after the other doesn't allow you to magically "print your file".
Perhaps try reading through this tutorial directory, top to bottom. By the time you've covered the one about scope (no, I'm not saying skip ahead to that one - go top to bottom!), you should have the info you need to start coding your project.
I read the tutorials, they haven't helped with documents, unless I'm REALLY ignorant and missed it 3 times in a row.
#29
Posted 01 April 2015 - 04:04 AM
Let's recap, and perhaps expand a bit. Say you have a bunch of lines, stored in a table for convenient access:
myDocument = { "This is some text.", "There are multiples lines of it.", "", "It's a fascinating read." }
Now let's say you want to write that to disk. We might use a for loop:
local myFile = fs.open("myFile.txt", "w") for i = 1, #myDocument do myFile.writeLine(myDocument[i]) end myFile.close()
And if you wanted to read it back at a later time (instead of manually defining your document within your script's code, like with the table declaration above), you're again using fs.open() to get the file handle you're going to work with, but this time you're switching to read mode:
local myFile, myDocument = fs.open("myFile.txt", "r"), {} for line in myFile.readLine do table.insert(myDocument, line) end myFile.close()
And again, to actually write all the lines in your table to the screen, you're looping:
for i = 1, #myDocument do print(myDocument[i]) end
It's quite possible to store your entire document within a single string, though the table solution makes it a lot easier to keep track of things. For example, if you wanted to insert a line in-between lines 2 and 3, you'd simply do:
table.insert(myDocument, 3, "This is an inserted line.")
#30
Posted 03 April 2015 - 10:55 PM
local myFile, myDocument = fs.open("myFile.txt", "r"), {}
for line in myFile.readLine do
table.insert(myDocument, line)
end
myFile.close()
without defining 'line', wouldn't this return an error?
pastebin.com/FVXWeY3D
i typed what you typed, but got an error on line 6. Help?
Edited by YUGATUG, 03 April 2015 - 10:56 PM.
#31
Posted 03 April 2015 - 10:59 PM
Edited by MKlegoman357, 03 April 2015 - 10:59 PM.
#33
Posted 04 April 2015 - 03:17 AM
#34
Posted 04 April 2015 - 04:47 AM
#35
Posted 04 April 2015 - 01:11 PM
MKlegoman357, on 03 April 2015 - 10:59 PM, said:
But line was never defined...
Also, i will add the for loop when i make the actual program, right now i want to figure out how to use fs.
Edited by YUGATUG, 04 April 2015 - 11:58 PM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users