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

Run programm in background

Started by Wilma456, 20 June 2016 - 02:56 PM
Wilma456 #1
Posted 20 June 2016 - 04:56 PM
How can I run a programm invisible in background? Multishell has a tab, but I dont want to see that programm. The programm in background use the modem API to connect with other computers and has no output.
ReBraLaCC #2
Posted 20 June 2016 - 05:10 PM
Well, you could always just make it a function as what you say gives no outputs, and maybe use
parallel.waitForAll()[\CODE]
Sewbacca #3
Posted 20 June 2016 - 05:47 PM

local program = loadfile('myPrograms/program')
local shell = loadfile('rom/programs/shell')
parallel.waitForAll(shell, program)
ReBraLaCC #4
Posted 20 June 2016 - 07:06 PM

local program = loadfile('myPrograms/program')
local shell = loadfile('rom/programs/shell')
parallel.waitForAll(shell, program)

^^ what i meant :)/>
H4X0RZ #5
Posted 20 June 2016 - 08:25 PM

local program = loadfile('myPrograms/program')
local shell = loadfile('rom/programs/shell')
parallel.waitForAll(shell, program)

^^ what i meant :)/>

That would create a shell instance on top of your shell instance -> lag. If you have access to multishell, just create a new tab and run the program in there. If you don't, first exit the current shell (maybe even a TLCO) and then "restart" the terminated coroutines + your custom ones. Maybe turn it into a coroutine manager so you can add/remove coroutines later on too.
ReBraLaCC #6
Posted 21 June 2016 - 09:20 AM
coroutine

and how so those wor?
Sewbacca #7
Posted 21 June 2016 - 12:58 PM

local program = loadfile('myPrograms/program')
local shell = loadfile('rom/programs/shell')
parallel.waitForAll(shell, program)

^^ what i meant :)/>

That would create a shell instance on top of your shell instance -> lag. If you have access to multishell, just create a new tab and run the program in there. If you don't, first exit the current shell (maybe even a TLCO) and then "restart" the terminated coroutines + your custom ones. Maybe turn it into a coroutine manager so you can add/remove coroutines later on too.

If you want to prevent an instance of the shell, then you have to edit the ROM, because all code is running just in one direction, so it is impossible to stop upper programs with code. Shell.exit() just stop the shell, after closing the last program (try it with lua), so creating an instance of the shell is the best alternate of running programs with the multishell. Also it is impossible to restart coroutines if you haven't the function.
Edited on 21 June 2016 - 10:58 AM
Wilma456 #8
Posted 21 June 2016 - 01:02 PM
Im working on a OS and I don't want to see the multishell tabs in my GUI. They destroy my GUI and doesent look good. They user can code his own programm for the OS and the programmm, who send and listen the modem must run every time in background.
H4X0RZ #9
Posted 21 June 2016 - 02:12 PM

local program = loadfile('myPrograms/program')
local shell = loadfile('rom/programs/shell')
parallel.waitForAll(shell, program)

^^ what i meant :)/>/>/>

That would create a shell instance on top of your shell instance -> lag. If you have access to multishell, just create a new tab and run the program in there. If you don't, first exit the current shell (maybe even a TLCO) and then "restart" the terminated coroutines + your custom ones. Maybe turn it into a coroutine manager so you can add/remove coroutines later on too.

If you want to prevent an instance of the shell, then you have to edit the ROM, because all code is running just in one direction, so it is impossible to stop upper programs with code. Shell.exit() just stop the shell, after closing the last program (try it with lua), so creating an instance of the shell is the best alternate of running programs with the multishell. Also it is impossible to restart coroutines if you haven't the function.

You can. Look at the Top Level Coroutine Override (TLCO). Basically let's you run code at BIOS level.

The only coroutines ran by the BIOS are an instance of shell/multishell and rednet.run . You can easily "restart" them.
Edited on 21 June 2016 - 12:14 PM