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

[LUA]Unexpected symbol?

Started by dan14941, 27 January 2013 - 12:08 PM
dan14941 #1
Posted 27 January 2013 - 01:08 PM
local a = "apple"
local b = "bed"
print("---------------")
print(" "..a.." | "..b..")
print("---------------")
When i run a program with this code in it it gives me an error? i need to know what ive done wrong
code:
theoriginalbit #2
Posted 27 January 2013 - 01:20 PM
Line 4 you haven't finished a string OR the function call. Get rid of the .." On the end and replace it with )

Also please next time tell us the exact error message that you are getting, it normally gives us useful info
dan14941 #3
Posted 27 January 2013 - 01:21 PM
Line 4 you haven't finished a string OR the function call. Get rid of the .." On the end and replace it with )

Also please next time tell us the exact error message that you are getting, it normally gives us useful info
i got unexpected symbol error

Line 4 you haven't finished a string OR the function call. Get rid of the .." On the end and replace it with )

Also please next time tell us the exact error message that you are getting, it normally gives us useful info
i got unexpected symbol error
and i need 2 off those ..a.. and ..b.. things in one line
theoriginalbit #4
Posted 27 January 2013 - 01:39 PM
i got unexpected symbol error
Yes and in this case its fine, you have 5 lines of code, but when there is more lines the exact message that displays helps.

and i need 2 off those ..a.. and ..b.. things in one line
Yes I understand that. but this is what it should be

print( "  "..a.." | "..b )
.. tells Lua to add whats on the right side to the left, when you have
" | "..b.."
it doesn't know what to concatenate AFTER b because you haven't told it, you have an unfinished string, so it tells you that there was an unexpected symbol, i.e. the " at the end.
dan14941 #5
Posted 27 January 2013 - 01:42 PM
i got unexpected symbol error
Yes and in this case its fine, you have 5 lines of code, but when there is more lines the exact message that displays helps.

and i need 2 off those ..a.. and ..b.. things in one line
Yes I understand that. but this is what it should be

print( "  "..a.." | "..b )
.. tells Lua to add whats on the right side to the left, when you have
" | "..b.."
it doesn't know what to concatenate AFTER b because you haven't told it, you have an unfinished string, so it tells you that there was an unexpected symbol, i.e. the " at the end.
thank but i put the ")" there
theoriginalbit #6
Posted 27 January 2013 - 02:38 PM
thank but i put the ")" there
That's still not going to fix the problem. It will fix half the problem. Lua is still not going to like the .." at the end, it is not correct to have an opening " without closing it. So you either need to remove the .." or make it .."" if you REALLY want to keep it in there.
mibac138 #7
Posted 28 January 2013 - 12:44 AM

print("---------------")
print(" "..a.." | "..B)/>/> -- without the /> i don't know how to remove this...
print("---------------")

Something like this? :P/>
Steve_Dao #8
Posted 28 January 2013 - 09:00 AM
Why dont you just try doing

local a = "apple"
local b = "bed"
print("---------------")
print(""..a.." | "..b.."") --you were missing another " to close the .."
print("---------------")
remiX #9
Posted 28 January 2013 - 09:38 AM
Or just

print(a .. " | " .. B)/>
theoriginalbit #10
Posted 28 January 2013 - 03:11 PM
-snip-

-snip-

-snip-

or just read what I suggested to him and find I told him that exact answer 3 times and he thinks he knows better and that isn't the problem… also mibac138 and remiX you would cause him another issue with using B instead of b.
ChunLing #11
Posted 28 January 2013 - 04:54 PM
dan14941, try TOB's suggestion, exactly as it appears in the second post

print( "  "..a.." | "..b )
If this doesn't work, then explain exactly what went wrong with it.
remiX #12
Posted 28 January 2013 - 05:47 PM
-snip-
or just read what I suggested to him and find I told him that exact answer 3 times and he thinks he knows better and that isn't the problem… also mibac138 and remiX you would cause him another issue with using B instead of b.

These forums add it automatically and include the "/>". No clue why…
theoriginalbit #13
Posted 28 January 2013 - 05:59 PM
These forums add it automatically and include the "/>". No clue why…
its because
B)/>
is this B)/> and in code it doesn't show it like that, the thing that scans for emoticon patterns doesn't ignore inside of code tags :/ thats why you would notice that I always put spaces around contents of the () to stop random emoticons
dan14941 #14
Posted 29 January 2013 - 01:19 AM
Or just

print(a .. " | " .. B)/>
When i run it it syas attempt to concentrate string and nill?
remiX #15
Posted 29 January 2013 - 01:38 AM
Did you change B )/> to b )
PixelToast #16
Posted 29 January 2013 - 01:52 AM
probably because B is capital
TheOddByte #17
Posted 29 January 2013 - 07:13 AM
probably because B is capital

Yeah and "b" has been declared but not "B" since lua is Type sensitive!
–b = bed
–B = Nothing
theoriginalbit #18
Posted 29 January 2013 - 11:17 AM
since lua is Type sensitive!
Case sensitive*
Lua is not at all Type sensitive. Sometimes I wish it was. But it's not.
TheOddByte #19
Posted 29 January 2013 - 12:15 PM
since lua is Type sensitive!
Case sensitive*
Lua is not at all Type sensitive. Sometimes I wish it was. But it's not.
Oh sorry Meant to write that..
But thanks for correcting me! :)/>
Kingdaro #20
Posted 29 January 2013 - 12:27 PM
since lua is Type sensitive!
Case sensitive*
Lua is not at all Type sensitive. Sometimes I wish it was. But it's not.
But type sensitivity is a nightmare! D:
tesla1889 #21
Posted 29 January 2013 - 02:00 PM
since lua is Type sensitive!
Case sensitive*
Lua is not at all Type sensitive. Sometimes I wish it was. But it's not.
But type sensitivity is a nightmare! D:
it can really save you though. it lets you know where you went wrong faster
ChunLing #22
Posted 29 January 2013 - 06:07 PM
I personally do prefer to be aware of and conserve type when it won't clutter a scope with too many identifiers. And I do find that this makes some tasks easier to track.
NeverCast #23
Posted 29 January 2013 - 06:08 PM
You could always create a type sensitive table? :D/>
ChunLing #24
Posted 29 January 2013 - 06:12 PM
I personally find it sufficient to pretend that Lua is type sensitive, particularly as I often do wish to reuse an identifier for a different type.
tesla1889 #25
Posted 29 January 2013 - 07:07 PM
i guess the only real benefit to type sensitivity is the possibility of function overloading, which is nice.

BTDubs we got way off topic
dan14941 #26
Posted 01 February 2013 - 12:30 PM
Did you change B )/> to b )
oops B is b\