Jump to content




File handle

api help

  • You cannot reply to this topic
7 replies to this topic

#1 Dereki2000

  • Members
  • 8 posts

Posted 15 August 2017 - 01: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?

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 15 August 2017 - 01:50 PM

Moved to Ask a Pro.

#3 Wilma456

  • Members
  • 187 posts
  • LocationGermany

Posted 15 August 2017 - 02:48 PM

German:
Wahrscheinlich existiert die Datei "programme.system" nicht.

English:
I think the file "programme.system" doesn't exists.

#4 Dereki2000

  • Members
  • 8 posts

Posted 16 August 2017 - 02:57 PM

It exists

#5 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 17 August 2017 - 06: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.

#6 Dereki2000

  • Members
  • 8 posts

Posted 19 August 2017 - 08: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?

#7 The Crazy Phoenix

  • Members
  • 136 posts
  • LocationProbably within 2 metres of my laptop.

Posted 19 August 2017 - 11:49 PM

"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),

#8 Dereki2000

  • Members
  • 8 posts

Posted 20 August 2017 - 07:38 PM

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

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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users