276 posts
Location
Fairbanks, Alaska
Posted 25 May 2016 - 07:04 PM
I'm making a program that downloads pastebins automatically, it looks good, and the data of what to download is a file. The trouble is, it doesn't write to a file properly? I have no idea why;
Pastebin is at: SkB9qExc
Required API at: pastebin get EPNh0HCv GUI
Test download file: Rxnhp2x5 (install as "pasteData")
Thanks!
-Bird
Edited on 25 May 2016 - 05:05 PM
212 posts
Location
Somewhere in this dimension... I think.
Posted 25 May 2016 - 08:09 PM
What do you mean "doesn't write properly"?
276 posts
Location
Fairbanks, Alaska
Posted 25 May 2016 - 08:18 PM
What do you mean "doesn't write properly"?
It errors when trying to write a downloaded file. When I call file.close() it says "Attempt to index, nil value"
3057 posts
Location
United States of America
Posted 25 May 2016 - 08:31 PM
That would mean the file wasn't opened, and was probably opened earlier but not closed. Try rebooting.
212 posts
Location
Somewhere in this dimension... I think.
Posted 25 May 2016 - 08:43 PM
You understand scoping right? Your "get" function uses file in the global scope, so does your main "stack". So when you opened "file" and get set "file" to equal what download contained, and when you tried to close "file" you were calling the close value of the string download contained.
Long story short: Use different variables or the Local keyword.
276 posts
Location
Fairbanks, Alaska
Posted 25 May 2016 - 09:48 PM
You understand scoping right? Your "get" function uses file in the global scope, so does your main "stack". So when you opened "file" and get set "file" to equal what download contained, and when you tried to close "file" you were calling the close value of the string download contained.
Long story short: Use different variables or the Local keyword.
Oh wow. Thank you! :)/> You'll get credited when this gets released.
Edited on 25 May 2016 - 07:48 PM