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

How to find name of program running.

Started by os.reboot(), 16 August 2012 - 08:05 PM
os.reboot() #1
Posted 16 August 2012 - 10:05 PM
I have a setup program and I want the program to copy itself to the computer.
How do I make a program find out what it's own name is.
Cranium #2
Posted 16 August 2012 - 10:09 PM
shell.getRunningProgram() Check it out here: Shell API
os.reboot() #3
Posted 16 August 2012 - 10:12 PM
I thought it was from the FS api. I didn't bother looking at the shell API. Thanks.
Cranium #4
Posted 16 August 2012 - 10:13 PM
No problem, that's what we're here for! :(/>/>
RoD #5
Posted 19 May 2014 - 08:19 PM
sorry for posting on a old thread, but what if i want a api to get the main program's dir? Is it possible without needing to type the dir manually in a api function?
Lignum #6
Posted 19 May 2014 - 08:28 PM
sorry for posting on a old thread, but what if i want a api to get the main program's dir? Is it possible without needing to type the dir manually in a api function?
Since an API doesn't have its own shell, you're going to have to pass a shell to the API. Then you can use shell.getRunningProgram().
RoD #7
Posted 19 May 2014 - 08:46 PM
sorry for posting on a old thread, but what if i want a api to get the main program's dir? Is it possible without needing to type the dir manually in a api function?
Since an API doesn't have its own shell, you're going to have to pass a shell to the API. Then you can use shell.getRunningProgram().
how so?
CometWolf #8
Posted 19 May 2014 - 09:34 PM
It's because os.loadAPI runs the API in it's own environment, which has access to the global environment. The global environment however, does not actually contain the shell API.
Edited on 19 May 2014 - 07:34 PM
RoD #9
Posted 19 May 2014 - 09:46 PM
It's because os.loadAPI runs the API in it's own environment, which has access to the global environment. The global environment however, does not actually contain the shell API.
Yea i got that, but how do i get a shell in the global environment?
Nevermind, i got it. I loaded the shell into the api using a function parameter.
Edited on 19 May 2014 - 07:55 PM