26 posts
Location
propably in front of his PC
Posted 28 March 2018 - 03:35 PM
Hello. I've got an error about a missing 'end' in my program, but every if is closed with an end. Do you find what's causing the error?
Code
hereError:
bios.lua:14: [string "apt"]:96: 'end' expected (to close 'if' at line 68)
1426 posts
Location
Does anyone put something serious here?
Posted 28 March 2018 - 03:39 PM
One should use
elseif instead of
else if. The latter is actually parsed as:
if #args > 2 then
...
else
if a1 == "remove" then
else
if a2 == "reinstall" then
--# etc...
26 posts
Location
propably in front of his PC
Posted 28 March 2018 - 07:38 PM
One should use
elseif instead of
else if. The latter is actually parsed as:
if #args > 2 then
...
else
if a1 == "remove" then
else
if a2 == "reinstall" then
--# etc...
I always code using else if and it should work like this:
if arg1 == "test1" then
...
else if arg1 == "test2" then
...
else
...
end
Edited on 28 March 2018 - 05:38 PM
3057 posts
Location
United States of America
Posted 28 March 2018 - 07:57 PM
1426 posts
Location
Does anyone put something serious here?
Posted 28 March 2018 - 07:59 PM
I always code using else if and it should work like this:
This form sort of makes sense in C-derived languages, where
else statements don't require braces. However, in languages without braces (Lua, Perl, Python, Ruby), you get some merged elseif token instead. On the bright side, it helps resolve
some forms of ambiguity.