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

Tabbed Multitasking Api

Started by AssossaGPB, 27 June 2014 - 03:22 PM
AssossaGPB #1
Posted 27 June 2014 - 05:22 PM
A friend was working on his os and asked me to write him a tabbed multitasking api for his os. I figured it couldn't be that hard, so I wrote it. After about 2 weeks of debugging here it is for the community to enjoy. And, yes I know that it is not true multitasking.

Download:
http://pastebin.com/V2pLdrdF
or
pastebin get V2pLdrdF tabmulti

Functions:
newTab(functionName,tabName) - Creates a new tab
setTabName(index,name) - Changes a tab's name at index to name
getTabName(index) - Gets a tab name at index
getTabNames() - Returns a table with all the tab names in their respective locations
getTabs() - Returns a table with all the tab coroutines in their respective locations
getCurrentTab() - Returns the index of the current tab
switchTab(index) - Switches the current tab to index
moveTab(pos1,pos2) - Moves tab at pos1 to pos2
closeTab(index) - Closes tab at index
runTabs() - Runs all the tabs
runCurrentTab() - Runs the current tab and pauses the other tabs
drawTabs() - Draws the tab bar
tabClick() - Checks for clicks on the tab bar and does the respective action (Does not support tab closing or tab moving currently)
tabRun(programName,tabName) - Runs a program in a tab

tabMain is a example main function to run the api, you may use it or write your own.

How to allow your programs/functions to work in the tabs:
In your functions/programs make sure to check is it is the current tab before drawing on the screen or checking for input. The api does not handle this yet, because I can not figure out how. If you do not do this, then all the tabs will be checking for input and drawing to the screen at the same time and it wont be too pretty.

Please point out any typos/bugs/glitches you find, any feedback will be appriciated!
Edited on 27 June 2014 - 03:24 PM
DubbelSoftware #2
Posted 10 March 2017 - 05:07 PM
This api does not work for my, i get an error on line 204.
Bomb Bloke #3
Posted 12 March 2017 - 03:54 AM
Assossa hasn't logged in for some time, and this API was written for a much older build of ComputerCraft than those which are current. You're probably better off using shell.openTab() / shell.switchTab() and the associated functions in the multishell API.