Difference between revisions of "Textutils.complete"

From ComputerCraft Wiki
Jump to: navigation, search
(Created page with "{{lowercase}} {{Function |name=textutils.complete |args= {{Type|string}} object name [, {{Type|table}} environment] |returns={{Type|table}} completion list |api=fs |addon=Comp...")
 
m
 
Line 4: Line 4:
 
|args= {{Type|string}} object name [, {{Type|table}} environment]
 
|args= {{Type|string}} object name [, {{Type|table}} environment]
 
|returns={{Type|table}} completion list
 
|returns={{Type|table}} completion list
|api=fs
+
|api=textutils
 
|addon=ComputerCraft
 
|addon=ComputerCraft
 
|desc=Added by ComputerCraft 1.74, textutils.complete() can be passed a partial variable name (or that of a key in a table), and returns a numerically indexed table containing strings that could be used to complete it. By default, it searches the environment used to load the textutils API, which contains its functions, and via metatables, access to _G. You can use getfenv() to obtain the environment your current script is working within (which contains ''its'' global variables, and via metatables, access to _G).
 
|desc=Added by ComputerCraft 1.74, textutils.complete() can be passed a partial variable name (or that of a key in a table), and returns a numerically indexed table containing strings that could be used to complete it. By default, it searches the environment used to load the textutils API, which contains its functions, and via metatables, access to _G. You can use getfenv() to obtain the environment your current script is working within (which contains ''its'' global variables, and via metatables, access to _G).

Latest revision as of 10:57, 19 July 2015


Grid Redstone.png  Function textutils.complete
Added by ComputerCraft 1.74, textutils.complete() can be passed a partial variable name (or that of a key in a table), and returns a numerically indexed table containing strings that could be used to complete it. By default, it searches the environment used to load the textutils API, which contains its functions, and via metatables, access to _G. You can use getfenv() to obtain the environment your current script is working within (which contains its global variables, and via metatables, access to _G).

If the element found represents a table, suggestions will have "." appended to them (in which case a new call, using the old search string concatenated with such a suggestion, would return the contents of that table). If a function, "(" is appended.

See also: fs.complete(), shell.complete(), shell.setCompletionFunction(), shell.completeProgram() and help.completeTopic().
Syntax textutils.complete(string object name [, table environment])
Returns table completion list
Part of ComputerCraft
API textutils

Examples

Grid paper.png  Example
Lists the suffixes of all keys in the current environment table beginning with "pa".
Code
textutils.tabulate( textutils.complete( "pa", getfenv() ) )
Output intutils. irs( rallel. (which could be concatenated to get the names of the paintutils API table, the "pairs" iterator function, and the parallel API table).



Grid paper.png  Example
Lists suffixes of all keys in the colors API beginning with "li".
Code
textutils.tabulate( textutils.complete( "colors.li", getfenv() ) )
Output ghtBlue ghtGray me