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

Program parameters

Started by michty, 14 December 2016 - 11:17 PM
michty #1
Posted 15 December 2016 - 12:17 AM
Hi everyone,

I have seen some programs have an ability to pass parameters down as you call the program, they were put in in a format:

> program -parameter

How you do you make these in a program? I not seen a tutorial on this topic.

Thanks.
EveryOS #2
Posted 15 December 2016 - 01:14 AM
Use args = … But with brackets around the …
I made a parser api for that formating but its buggy.
Dog #3
Posted 15 December 2016 - 01:23 AM
To clarify what EveryOS said - three dots (…) represent command line arguments. If you just use … then you'll capture the first command line argument. If you want to capture multiple command line arguments you'll need to capture them in a table like so…

local tArgs = { ... }

From there tArgs[1] will be the first argument, tArgs[2] will be the second, etc.
Edited on 15 December 2016 - 12:24 AM