Jump to content




fs.readLine( ) help!


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

#1 TheJebForge

  • Members
  • 128 posts

Posted 04 November 2014 - 01:35 PM

Im making an OS. But there's an error!

Main File:
...
function loadIcons()
tot = fs.open("wtOS/deskto/tot","r")
dicons = tot.readLine() --<That thing actually returns notting!
tot.close()
dicons = tonumber(dicons)
for i = 1,dicons,1 do
ic = fs.open("wtOS/deskto/sh"..i,"r")
sx[i] = ic.readLine()
sy[i] = ic.readLine()
sip[i] = ic.readLine()
sptp[i] = ic.readLine()
sn[i] = ic.readLine()
ic.close()
end
end
...
(dots - not in code, just showing that piece of code)

wtOS/deskto/tot:
0

And dicons = nil! Whyyy?

Edited by Thejebforge, 04 November 2014 - 04:52 PM.


#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 04 November 2014 - 03:15 PM

tot.readLine() is returning something that cant be converted into a number, eg "hello". Try adding some prints in to see what it's doing. Also post the files in question (wtOs/deskto/tot).

#3 TheJebForge

  • Members
  • 128 posts

Posted 04 November 2014 - 04:44 PM

tot.readLine() have to return "0"! Look wtOS/deskto/tot thing
But it return nil or something else!

#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 04 November 2014 - 05:35 PM

What does it return instead? What makes you think it isn't returning "0" if you don't know what it is returning?

#5 TheJebForge

  • Members
  • 128 posts

Posted 04 November 2014 - 05:38 PM

It returning ""! Nil! Nothing!

It returns nothing!

#6 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 04 November 2014 - 08:23 PM

Try doing this
print( type( dicons ) )
to see if it returns nil or a space character

#7 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 04 November 2014 - 09:47 PM

View PostThejebforge, on 04 November 2014 - 05:38 PM, said:

It returning ""! Nil! Nothing!

It returns nothing!

An empty string and nil are two different values. You still didn't answer my other question, what symptoms does the program display to cause you to believe that that function call is returning nil?

#8 Bomb Bloke

    Hobbyist Coder

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

Posted 04 November 2014 - 10:42 PM

View PostThejebforge, on 04 November 2014 - 04:44 PM, said:

tot.readLine() have to return "0"! Look wtOS/deskto/tot thing
But it return nil or something else!

... does that file contain 0 (like you're saying here), or does it contain o (like you're saying in your first post)? Just as nil and "" aren't the same thing, 0 and o aren't the same thing either. You must be specific!

#9 TheJebForge

  • Members
  • 128 posts

Posted 05 November 2014 - 05:31 AM

When I trying print that variable, after tot.readLine(). The print crashes with error string needed, got nil.

Edited by Thejebforge, 05 November 2014 - 05:31 AM.


#10 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 05 November 2014 - 05:39 AM

No, it doesn't. Please actually test things instead of just lying about the results.

#11 TheJebForge

  • Members
  • 128 posts

Posted 05 November 2014 - 01:34 PM

Now nevermind! I discontinued my OS! You must be hear about that! Im making NxOS and it haven't got this error!

#12 Saldor010

  • Members
  • 467 posts
  • LocationThe United States

Posted 05 November 2014 - 06:51 PM

View PostThejebforge, on 05 November 2014 - 01:34 PM, said:

Now nevermind! I discontinued my OS! You must be hear about that! Im making NxOS and it haven't got this error!

Please, don't make operating systems if you can't understand basic errors such as this one. I don't want to be mean, but your OS probably isn't going to be very good if you don't understand at least the intermediates of Lua fully.

#13 TheJebForge

  • Members
  • 128 posts

Posted 05 November 2014 - 07:27 PM

That been special error! In other script that works fine! I have use it in JebOS, JacOS, ctOS, but in wtOS it bugged! In NxOS its works fine too!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users