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

run a program in any directory

Started by darkhenmore, 08 September 2012 - 08:13 PM
darkhenmore #1
Posted 08 September 2012 - 10:13 PM
hi,
i want to know if there is a way that i can make a program that you can run when your in any directory, like the built in programs.
MysticT #2
Posted 08 September 2012 - 10:17 PM
You have to add the path to the program (the directory containing it) to the programs path, using shell.setPath.
darkhenmore #3
Posted 08 September 2012 - 10:26 PM
You have to add the path to the program (the directory containing it) to the programs path, using shell.setPath.
When i do that it stops all the normal programs from running like dir or list
MysticT #4
Posted 08 September 2012 - 11:41 PM
That's because you are replacing the path. Try adding it like this:

shell.setPath(shell.getPath()..":/The/Path/To/Your/Programs")
GopherAtl #5
Posted 08 September 2012 - 11:42 PM
shell.setPath(shell.getPath()..":"..newPath)

there's a similar function in the help api to add to the help path. Path is checked in order, if you want yours to run first, like you made a better edit command, reverse the order and do newPath..":"..shell.getPath()

:edit: damn ninjas. :D/>/>