26 posts
Location
propably in front of his PC
Posted 26 March 2018 - 06:55 PM
How do I code arguments.
I want to code for e.g. apt install nano
I want to code it like this:
if arg1 = "install" then
if arg2 = "nano" then
...
end
else if arg1 = "remove" then
if arg2 = "nano" then
...
end
else
print("...")
end
But how can I save the arguments into variables?
3057 posts
Location
United States of America
Posted 27 March 2018 - 04:40 AM
Edited on 27 March 2018 - 02:41 AM
26 posts
Location
propably in front of his PC
Posted 27 March 2018 - 08:48 AM
I know how to make a variable, I want to know what to put behind the '='. And your link doesn't help me as well…
1426 posts
Location
Does anyone put something serious here?
Posted 27 March 2018 - 09:08 AM
I know how to make a variable, I want to know what to put behind the '='. And your link doesn't help me as well…
Literally just
…
Edited on 27 March 2018 - 07:08 AM
26 posts
Location
propably in front of his PC
Posted 27 March 2018 - 09:29 AM
I know how to make a variable, I want to know what to put behind the '='. And your link doesn't help me as well…
Literally just
…
Thanks. But now I get the following message when launching my program:
bios.lua:14: [string "test"]:3: 'then' expected.
In line 3 there's:
if arg1 = "Test" then
1426 posts
Location
Does anyone put something serious here?
Posted 27 March 2018 - 09:31 AM
In line 3 there's:
if arg1 = "Test" then
You need to use double equals. So your code should read:
if arg1 == "Test" then
Most languages use a single equal sign for assignment, and two for equality tests. It's a bit odd, but makes sense when you consider the history of it.
26 posts
Location
propably in front of his PC
Posted 27 March 2018 - 09:35 AM
In line 3 there's:
if arg1 = "Test" then
You need to use double equals. So your code should read:
if arg1 == "Test" then
Most languages use a single equal sign for assignment, and two for equality tests. It's a bit odd, but makes sense when you consider the history of it.
Big thanks. The equal sign was the problem. I got a bit confused from too many programing languages inside of my head. :lol:/>
Edited on 27 March 2018 - 07:35 AM