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

make program with arguments

Started by etopsirhc, 22 March 2012 - 07:47 AM
etopsirhc #1
Posted 22 March 2012 - 08:47 AM
as the topic says i would like to make a program that accepts arguments , but i cant seem to find any info about it.
all i find is info about funtion arguments ><

please help , thank you.
Luanub #2
Posted 22 March 2012 - 09:04 AM
Try capturing them as a var using the { } brackets.

So put something like this at the start of your code..

local arg = { ... }

You should then be able to work with each argument in the code by doing something like:


if arg[1] == "y" then
  do something
end
etopsirhc #3
Posted 22 March 2012 - 03:59 PM
ok , i'll try that now then =D
dremp #4
Posted 15 January 2013 - 12:05 AM
What if i need to press Ctrl + Alt + 7 to make { and Ctrl + Alt + 0 to make } ?? (danish keyboard)
theoriginalbit #5
Posted 15 January 2013 - 12:49 AM
Try capturing them as a var using the { } brackets.

So put something like this at the start of your code..

local arg = { ... }

You should then be able to work with each argument in the code by doing something like:


if arg[1] == "y" then
  do something
end

You can also the validate the number of args with


if #args ~= 4 then
  -- show usage
end
theoriginalbit #6
Posted 15 January 2013 - 12:50 AM
What if i need to press Ctrl + Alt + 7 to make { and Ctrl + Alt + 0 to make } ?? (danish keyboard)

Maybe modify the edit program so that when a key such as an F key is pressed it will add them to the text…
remiX #7
Posted 15 January 2013 - 01:34 AM
Click Ctrl first and then do the shortcuts.

Alternatively, you can edit the edit program if it's single player.
Or if it's multiplayer, copy the edit program to the computer and then edit the program to use the Alt key to bring up the menu