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

What have I missed?

Started by Cranium, 25 November 2012 - 09:30 AM
Cranium #1
Posted 25 November 2012 - 10:30 AM
I am getting an error with my new program that I apparently missed before. It occurs when trying to post data to Pastebin, and I am getting "attempt to concatenate nil and string" on line 396. The only variable on that line is postText, which is properly defined on line 359.
If anyone could take a look at this, I would be very grateful.
Code here: http://pastebin.com/DPJVtctz
Goof #2
Posted 25 November 2012 - 11:56 AM
"api_paste_code="..textutils.urlEncode(postText)

Should be:

"api_paste_code="..textutils.urlEncode(postText)..&..


???
dissy #3
Posted 25 November 2012 - 12:06 PM
The ampersands go between each key=pair set. There doesn't need to be one at the very end (Although most well-coded CGI scripts will just ignore it instead of error)

I think the error is with line 359, where you define the postText variable to be local.
It enters a while loop, and an if, so might not have access to the variable up two levels of scope. But I'm not possitive that is it.
Cranium #4
Posted 25 November 2012 - 12:09 PM
Nah, that's not it. The last line in the http.post can't have the "&" in it, otherwise I'll get a bad response from Pastebin.

The ampersands go between each key=pair set. There doesn't need to be one at the very end (Although most well-coded CGI scripts will just ignore it instead of error) I think the error is with line 359, where you define the postText variable to be local. It enters a while loop, and an if, so might not have access to the variable up two levels of scope. But I'm not possitive that is it.
I did test the variable, because that is the first thing I thought of too. I had it save that text to a file, and it copied perfectly. I'll try making it a global and see if that worked.

Edit: Nope, changing it to global did nothing.
Edited on 25 November 2012 - 11:10 AM
Goof #5
Posted 25 November 2012 - 12:11 PM
Then what about just this:

"api_paste_code="..textutils.urlEncode(postText)..

because before that, you have two ..

.. "api_paste_code="..textutils.urlEncode(postText)..

is that it?

I'm glad if i could help you:-D


Edit: well, i 'm sorry but right now my brain is totally blacked out… I will Take a bigger look at your 'smartpaste' and then tell you, if i find anything special, or wrong..
Cranium #6
Posted 25 November 2012 - 12:16 PM
Then what about just this: "api_paste_code="..textutils.urlEncode(postText).. because before that, you have two .. .. "api_paste_code="..textutils.urlEncode(postText).. is that it? I'm glad if i could help you:-D
In this code, I am concatenating several strings together. By putting the .. at the end of the lines, it allows me to make several lines instead of one large line.

print("These are the same thing")
print(
"These "..
"are "..
"the "..
"same "..
"thing"
)
Goof #7
Posted 25 November 2012 - 12:20 PM
I am sorry then… I will take a bigger look at your code, then. If i find anything wrong, i would post it directly to you.

:-P
dissy #8
Posted 25 November 2012 - 12:22 PM
My appologies, hmm I really don't see what is wrong with that code. One of those "Grr it should work!" kinda things ;}
I hope more eyes will be able to help, and you figure it out. Good luck!
Kingdaro #9
Posted 25 November 2012 - 01:01 PM
It's not line 396, it's actually line 395. "pasteName" should be "postName", I believe.
remiX #10
Posted 25 November 2012 - 01:08 PM
It's not like 396, it's actually line 395. "pasteName" should be "postName", I believe.

Haha, that's the problem. Nice eye. Surprised a lot of people missed that…

After that this line then errors:
write(string.rep(" ", (b-(sResponse/2)-2)))

And cranium: Line 424 you made made mistakes:

term.setTExttColor(colors.white)

edit: after that, clicking 'ok' each time it uploads to pastebin goes back to 'save as' and keeps uploading
Cranium #11
Posted 25 November 2012 - 01:11 PM
OMG….. wow.
I am going to have to fix those errors… but at least we found the first problem, just to find more ;_;