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

shell.run - Please dont print to the console...

Started by DaWooShit, 11 November 2012 - 10:23 AM
DaWooShit #1
Posted 11 November 2012 - 11:23 AM
I'm trying to test if a file can be launched as a program.
I have been using shell.run and see if it returns true or false, my problem is that this command prints "No such program" (if the file can not be launched) to the console and this breaks my layout.
So what do I do?
Orwell #2
Posted 11 November 2012 - 11:29 AM

local programName = 'testProgram'
local succes  = pcall( shell.run(programName) )
pcall returns true when the function inside succeeds (and as other parameters the results from the function call). It suppresses error messages.
Cloudy #3
Posted 11 November 2012 - 11:45 AM
I'm trying to test if a file can be launched as a program.
I have been using shell.run and see if it returns true or false, my problem is that this command prints "No such program" (if the file can not be launched) to the console and this breaks my layout.
So what do I do?

Check if shell.resolve works first.
MathManiac #4
Posted 11 November 2012 - 12:43 PM
The error means that the path you gave it isn't a valid program path. Make sure that the file path you gave it is valid.
Espen #5
Posted 11 November 2012 - 01:21 PM

local programName = 'testProgram'
local succes  = pcall( shell.run(programName) )
pcall returns true when the function inside succeeds (and as other parameters the results from the function call). It suppresses error messages.
You have to pass the function reference with its arguments as separate arguments to pcall().
That is, the correct call would be:
pcall( shell.run, programName )

Edit: Changed the wording a bit to prevent possible confusion (hopefully)^^.
Edited on 11 November 2012 - 12:23 PM
Orwell #6
Posted 11 November 2012 - 01:27 PM

local programName = 'testProgram'
local succes  = pcall( shell.run(programName) )
pcall returns true when the function inside succeeds (and as other parameters the results from the function call). It suppresses error messages.
You have to pass the function reference with its arguments as separate arguments to pcall().
That is, the correct call would be:
pcall( shell.run, programName )

Edit: Changed the wording a bit to prevent possible confusion (hopefully)^^.
Oh yea, thanks. Totally didn't see that. :unsure:/>/>