Jump to content




how to do my logic?



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

#21 IsaacTBeast

  • Members
  • 86 posts
  • LocationI 'm inside your brian

Posted 01 June 2014 - 11:10 AM

 Bomb Bloke, on 01 June 2014 - 02:32 AM, said:

92:

app.write(http.get( "https://raw.githubusercontent.com/iansapelino/islxcc/master/Programs/"..args[2] ).readAll())

You guys are misreading the error - an "attempt to index nil" doesn't mean that something like args[2] is nil, it means that something like args is nil. That can't be true, so presumably it doesn't like the attempt to index "readAll" from within "http.get()". Or "get" from within "http".

This could mean the http API isn't enabled, or that there's some other problem with the attempt to get the website handle.

It's a bad idea to do the "get" and the "read" on one line anyway. That means you don't retain the handle, which you should be closing after the read (impossible if you didn't keep the pointer):

local webHandle = http.get( "https://raw.githubusercontent.com/iansapelino/islxcc/master/Programs/"..args[2] )
app.write(webHandle.readAll())
webHandle.close()

Though I'm still suspecting the error is happening within some API this script is calling - I'd expect the full error to include information about the name of the file within which the error occurred.

THANK YOU!! :D and God Bless :)

#22 Bomb Bloke

    Hobbyist Coder

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

Posted 01 June 2014 - 11:35 AM

Wait, what? That wasn't supposed to fix your specific error... :blink:

#23 IsaacTBeast

  • Members
  • 86 posts
  • LocationI 'm inside your brian

Posted 01 June 2014 - 11:42 AM

 Bomb Bloke, on 01 June 2014 - 11:35 AM, said:

Wait, what? That wasn't supposed to fix your specific error... :blink:

WHAT?!?!! xD... but thanks if thats not the answer.. but how do you if the application idoesn't exist in the repository?

#24 Bomb Bloke

    Hobbyist Coder

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

Posted 01 June 2014 - 12:01 PM

Well, if you wanted to check if the http.get() request was successful, you could do:

local webHandle = http.get( "https://raw.githubusercontent.com/iansapelino/islxcc/master/Programs/"..args[2] )

if webHandle then
  app.write(webHandle.readAll())
  webHandle.close()
else error("Couldn't find "..args[2].." in the repo.") end







2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users