This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
cptdeath58's profile picture

Program reading files

Started by cptdeath58, 14 May 2014 - 10:19 PM
cptdeath58 #1
Posted 15 May 2014 - 12:19 AM
I want to know if it is possible to make a program read multiple lines and set multiple variables.
Ex:
SpoilerLine 1:Read This line and set variable x
Line 2:Read this line and set variable y
gezepi #2
Posted 15 May 2014 - 12:26 AM
If you're looking to make a configuration file there was a post 3 days ago that addressed the same issue. TheOriginalBIT has an API called ccConfig in his thread here.

If you want to work on one yourself look at the FS API. You would open the file for reading, then read in each line at a time. Then use some kind of string parsing to separate the name from the value.
cptdeath58 #3
Posted 28 May 2014 - 04:34 PM
Found out how just a few days ago.
Pie = fs.open( "lol", "r" )
Pie.readLine(1)
Pie.readLine(2)