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

File handle

Started by Dereki2000, 15 August 2017 - 12:20 PM
Dereki2000 #1
Posted 15 August 2017 - 02:20 PM
Hallo, First I Show My Problem in German and An then in English.

Ich habe versucht Systemdaten in dateien zu speichern und dann zu laden:

   datei = fs.open("programme.system", "r")
   p1 = datei.readLine()
   datei.close()

Aber der Computer sagt in Zeile 2 gibt es eine "attempt to index - a nil value"
Warum?

I tried to write data in a file and load it. I wrote:

   datei = fs.open("programme.system", "r")
   p1 = datei.readLine()
   datei.close()

But the computer says "attempt to call index - a nil value" whY?
Lyqyd #2
Posted 15 August 2017 - 02:50 PM
Moved to Ask a Pro.
Wilma456 #3
Posted 15 August 2017 - 03:48 PM
German:
Wahrscheinlich existiert die Datei "programme.system" nicht.

English:
I think the file "programme.system" doesn't exists.
Dereki2000 #4
Posted 16 August 2017 - 03:57 PM
It exists
Bomb Bloke #5
Posted 17 August 2017 - 07:26 AM
You haven't provided the full error. Which line number is specified?

It does seem most likely that your specified file doesn't exist, though. Remember that the fs API uses absolute paths - if the file isn't on the root of your drive, you might need to use shell.resolve().

The next most likely scenario is that the file is locked. Make sure you don't already have it open elsewhere.
Dereki2000 #6
Posted 19 August 2017 - 09:13 PM
Ok, i think I know what you mean. Buy have the path to start at C:\ or at the folder of this PC?
The Crazy Phoenix #7
Posted 20 August 2017 - 12:49 AM
"Absolute path" refers to the path you'd use to access it if your current directory were the root directory.

For example, the shell program's absolute path is "rom/programs/shell" (or "/rom/programs/shell", the "/" forces it to be interpreted as absolute),
Dereki2000 #8
Posted 20 August 2017 - 08:38 PM
Okay, I'll try it. Thank you very very much.

Okay, I'll try it. Thank you very very much.