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

Checking if Program Exists

Started by Strite, 28 March 2014 - 12:32 AM
Strite #1
Posted 28 March 2014 - 01:32 AM
Hello World. What's up?
I'm just wondering, is there a way to check if a program exists?
A stupid example would be:


local programName = "program"
--conditional statement here to check if program exists, if it does:
print ("true")
--else:
print ("false")

Is a there a way to roughly imitate this example? If yes, please let me know.
Thanks for the attention.
Bomb Bloke #2
Posted 28 March 2014 - 01:39 AM
Sure, fs.exists() is what you're after.

Say you want to know if a given file exists on the root of your drive:

if fs.exists("myProgram") then ...

Say you want to know if a given file exists in the same folder as you're running the script in:

if fs.exists(shell.resolve(".").."/myProgram") then ...
Strite #3
Posted 28 March 2014 - 01:41 AM
Thanks, Bomb Bloke! That really helped.
Happy to see you're still here helping newbies like me - lol'.
As always, thanks for the attention!