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

error message For input string

Started by Hydrotronics, 19 February 2016 - 11:26 AM
Hydrotronics #1
Posted 19 February 2016 - 12:26 PM
what is this? what does it actually mean?

yes that literally is my question… I did look! Just didn't find an adequet answer (is that how you spell adequet?)
KingofGamesYami #2
Posted 19 February 2016 - 12:59 PM
http://www.computercraft.info/forums2/index.php?/topic/25907-program-returning-for-input-string7count/page__view__findpost__p__245069

http://www.computercraft.info/forums2/index.php?/topic/17915-for-input-string/page__view__findpost__p__171936

http://www.computercraft.info/forums2/index.php?/topic/6921-error-for-input-string/page__view__findpost__p__58532
Morganamilo #3
Posted 19 February 2016 - 04:44 PM
In terms of Lua's "though process" It's less to do with variables starting with numbers, and more do do with numbers with invalid symbols.

for example 4e34 and 0x3f are both valid numbers in Lua.

For input string: "something" just means you've written a number Lua can't make sense of.
Hydrotronics #4
Posted 22 February 2016 - 05:54 PM
ok thx, so it's just that lua doesn't like variables with numbers infront. I now realise my mistake of havign a variable called 1stcharpos. i shall change that
Dragon53535 #5
Posted 22 February 2016 - 06:34 PM
It's not just Lua, it's any language. Java, C, C++, C#. All of those languages, and more that I've not had the pleasure of using, do not allow a number to lead a variable name. They also don't allow most symbols, with _ at least being accepted.

local VarName
--#Valid
local 1VarName
--#Invalid
local VarName1
--#Valid
Edit: Heck the forums code tool recognized that it's invalid
Edited on 22 February 2016 - 05:34 PM
KingofGamesYami #6
Posted 22 February 2016 - 07:19 PM
Edit: Heck the forums code tool recognized that it's invalid

Actually, it's trying to represent it as a number.


local 1VarName
local i = 1
local varname = 1VarName
Edited on 22 February 2016 - 06:19 PM
Dragon53535 #7
Posted 22 February 2016 - 10:32 PM
Actually, it's trying to represent it as a number.
Well yes, but that's also how the compiler/interpreter views it.
Hydrotronics #8
Posted 24 February 2016 - 06:31 PM
lol k got it! :)/> Thank you very much