Difference between revisions of "Textutils (API)"

From ComputerCraft Wiki
Jump to: navigation, search
m (Number (type) [gone] -> int (type))
(Updated to API overview v2)
Line 1: Line 1:
 
{{NeedsWork|Needs <s>5</s> 3 function pages, 2 function descriptions. ''[[User:AfterLifeLochie|AfterLifeLochie]] 02:40, 29 November 2012 (MSK)''}}
 
{{NeedsWork|Needs <s>5</s> 3 function pages, 2 function descriptions. ''[[User:AfterLifeLochie|AfterLifeLochie]] 02:40, 29 November 2012 (MSK)''}}
 
 
Text utilities is used to mess around with text easier.
 
Text utilities is used to mess around with text easier.
  
Its functions include:
+
<table style="width: 100%; border: solid 1px black; margin: 2px; border-spacing: 0px;">
{| border="1" cellpadding="2" cellspacing="0"
+
<tr><td colspan="2" style="font-weight: bold; font-size: large; padding-bottom: .3em; border-bottom: solid #C9C9C9 1px; background: #D3FFC2; line-height:28px;">
!style="background:#EEE" width="200px"|Method name
+
[[File:Grid_disk.png|24px]]&nbsp;&nbsp;
!style="background:#EEE" width="*"|Description
+
Textutils (API)
|-
+
</td></tr>
|[[textutils.slowPrint|textutils.slowPrint]]([[string (type)|string]] text, [[int (type)|int]] rate)
+
 
|Slowly prints the text. Only difference is, it leaves a new-line after it.
+
<tr><td style="width: 350px; background: #E0E0E0; padding: .4em; font-weight:bold;">Method Name</td><td style="background: #E0E0E0; padding: .4em; font-weight:bold;">Description</td></tr>
|-
+
 
|[[textutils.slowWrite|textutils.slowWrite]]([[string (type)|string]] text, [[int (type)|int]] rate)
+
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[textutils.slowPrint|textutils.slowPrint]]([[string (type)|string]] text, [[int (type)|int]] rate)</td>
|Slowly writes the text.
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Slowly prints the text. Only difference is, it leaves a new-line after it.</td></tr>
|-
+
 
|[[textutils.formatTime|textutils.formatTime]]([[int (type)|int]] time, [[boolean (type)|bool]] TwentyFourHour)
+
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[textutils.slowWrite|textutils.slowWrite]]([[string (type)|string]] text, [[int (type)|int]] rate)</td>
|Put a time into it, and it spews it out in a different format. For example:
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Slowly writes the text.</td></tr>
local time = os.time()
+
 
 +
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[textutils.formatTime|textutils.formatTime]]([[int (type)|int]] time, [[boolean (type)|bool]] TwentyFourHour)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Put a time into it, and it spews it out in a different format. Example: print(textutils.formatTime(os.time(), false))</td></tr>
 +
 
 +
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[textutils.tabulate|textutils.tabulate]]([[table (type)|table]] table, [[table (type)|table]] table2, ...)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Prints tables in an ordered form. Each table is a row, columns' width is auto-adjusted.</td></tr>
 +
 
 +
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[textutils.pagedTabulate|textutils.pagedTabulate]]([[table (type)|table]] table, [[table (type)|table]] table2, ...)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">A description is required.</td></tr>
 +
 
 +
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[textutils.pagedPrint|textutils.pagedPrint]]([[string (type)|string]] string, [[string (type)|string]] confirmation_lines)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Prints a string onto the screen, but waits for confirmation before scrolling down.</td></tr>
 +
 
 +
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[textutils.serialize|textutils.serialize]]([[table (type)|table]] table)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns a string representation of the table t for storage or transmission.</td></tr>
 +
 
 +
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[textutils.unserialize|textutils.unserialize]]([[string (type)|string]] text)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns a table reassembled from the string s.</td></tr>
 +
 
 +
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[textutils.urlEncode|textutils.urlEncode]]([[string (type)|string]] text)</td>
 +
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Makes a string safe to encode into a url. Spaces are replaced with +s. Unsafe characters such as '\', '£' and '}' are translated into ASCII code and preceded with a % for transmission. For reference visit: [http://www.blooberry.com/indexdot/html/topics/urlencoding.htm].</td></tr>
 +
</table>
  
print(textutils.formatTime(time, false))
 
|-
 
|[[textutils.tabulate|textutils.tabulate]]([[table (type)|table]] table, [[table (type)|table]] table2, ...)
 
|Prints tables in an ordered form. Each table is a row, columns' width is auto-adjusted.
 
|-
 
|[[textutils.pagedTabulate|textutils.pagedTabulate]]([[table (type)|table]] table, [[table (type)|table]] table2, ...)
 
|<no description given>
 
|-
 
|[[textutils.pagedPrint|textutils.pagedPrint]]([[string (type)|string]] string, [[string (type)|string]] confirmation_lines)
 
|Prints a string onto the screen, but waits for confirmation before scrolling down.
 
|-
 
|[[textutils.serialize|textutils.serialize]]([[table (type)|table]] table)
 
|Returns a string representation of the table t for storage or transmission.
 
|-
 
|[[textutils.unserialize|textutils.unserialize]]([[string (type)|string]] text)
 
|Returns a table reassembled from the string s.
 
|-
 
|[[textutils.urlEncode|textutils.urlEncode]]([[string (type)|string]] text)
 
|Makes a string safe to encode into a url. Spaces are replaced with +s. Unsafe characters such as '\', '£' and '}' are translated into ASCII code and preceded with a % for transmission. For reference visit: [http://www.blooberry.com/indexdot/html/topics/urlencoding.htm].
 
|}
 
  
 
[[Category:APIs]]
 
[[Category:APIs]]

Revision as of 22:53, 30 November 2012

This page needs some serious TLC, stat!
Please help us by cleaning it, fixing it up, or sparing it some love.
(Reason: Needs 5 3 function pages, 2 function descriptions. AfterLifeLochie 02:40, 29 November 2012 (MSK))

Text utilities is used to mess around with text easier.

Grid disk.png   Textutils (API)

Method NameDescription
textutils.slowPrint(string text, int rate) Slowly prints the text. Only difference is, it leaves a new-line after it.
textutils.slowWrite(string text, int rate) Slowly writes the text.
textutils.formatTime(int time, bool TwentyFourHour) Put a time into it, and it spews it out in a different format. Example: print(textutils.formatTime(os.time(), false))
textutils.tabulate(table table, table table2, ...) Prints tables in an ordered form. Each table is a row, columns' width is auto-adjusted.
textutils.pagedTabulate(table table, table table2, ...) A description is required.
textutils.pagedPrint(string string, string confirmation_lines) Prints a string onto the screen, but waits for confirmation before scrolling down.
textutils.serialize(table table) Returns a string representation of the table t for storage or transmission.
textutils.unserialize(string text) Returns a table reassembled from the string s.
textutils.urlEncode(string text) Makes a string safe to encode into a url. Spaces are replaced with +s. Unsafe characters such as '\', '£' and '}' are translated into ASCII code and preceded with a % for transmission. For reference visit: [1].