I probably should have asked this months ago, but here's what I found.
As soon as CC 1.6 was released I went to check how you did the multishell system by opening the 'rom/programs/advanced/multishell' file. After examining it, I found one thing about the programs' IDs and how they are assigned and managed.
Imagine this scenario: I run program A and, before it ends, run program B and capture it's tab ID. Now, program A ends, but program B is still running. Lets say I then want to change the title of the program B using the ID I captured before. I call all functions correctly, but the title doesn't change no matter what I do.
The title didn't change, because when program A ended, program B's ID changed.
Now, to prove this, I made these two programs:
test:
print("testing ")
local s = tonumber(...)
if s then
sleep(s)
end
run:
local id1 = multishell.launch({}, "test", 1)
local id2 = multishell.launch({}, "test", 10)
multishell.setTitle(id2, "test2")
multishell.setFocus(id2)
print("ID 1: ", id1)
print("ID 2: ", id2)
sleep(5)
multishell.setTitle(id2, "testing")
print("ID 2: ", multishell.getFocus())
Reproduction steps:
- Put both programs in the root directory of the computer. Make sure the first program is named 'test'.
- Run the second program ('run').
- Quickly open the tab named 'test' and press any key when it asks you to, to close the program.
- Now, quickly switch to the tab named 'test2' and wait until it exits.
If you have run everything correctly, the end result should look something like this:
Spoiler
The reason the ID changes is because of how tabs and their IDs are stored inside multishell. Tabs are stored in one table. Each tab is inserted using table.insert and removed using table.remove. The ID of the tab is the index of it in the table.
My question is: is this an intentional design feature or an unwanted bug?
To me, it looks like Dan200 simply didn't notice this problem.
BTW, how do I summon Dan200 to answer my question :D/>/> because I don't think he comes here often.