Namespace IO
Defined in: </ScriptBot/trunk/src/app/run.js>.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
A collection of items related to helping with input/output, as well as loading other script files.
|
| Field Attributes | Field Name and Description |
|---|---|
| <static> |
IO.lineBreak
The line separator used by the system.
|
| <static> |
IO.path
The path to the folder where the shell or bat file to start the bot was run.
|
| <static> |
IO.separator
The path separator used by the system.
|
| <static> |
IO.slash
Forward or backward slash depending on which OS the bot is being run.
|
| Method Attributes | Method Name and Description |
|---|---|
| <static> |
IO.fetchURL(url, asLines)
Gets contents of the specified URL.
|
| <static> |
IO.fileExists(path)
Checks if the given file exists.
|
| <static> |
IO.include(path, relative)
Includes the given script file into the current runtime.
|
| <static> |
IO.objectExists(name)
Checks if the given object file exists.
|
| <static> |
IO.readFile(path, asLines)
Reads in the specified file.
|
| <static> |
IO.readObject(name, funct)
Returns an object previously saved via #writeObject.
|
| <static> |
IO.writeFile(path, contents, append)
Writes the given contents to the specified path.
|
| <static> |
IO.writeObject(name, object, funct, tabin)
Writes the given object out to a file such that it can be read in via #readObject.
|
Namespace Detail
IO
A collection of items related to helping with input/output, as well as loading other script files.
Author: AMcBain, 2008.
Author: AMcBain, 2008.
- Since:
- 2.0.1
Field Detail
<static>
IO.lineBreak
The line separator used by the system.
<static>
{string}
IO.path
The path to the folder where the shell or bat file to start the bot was run.
<static>
{string}
IO.separator
The path separator used by the system.
<static>
{string}
IO.slash
Forward or backward slash depending on which OS the bot is being run.
Method Detail
<static>
IO.fetchURL(url, asLines)
Gets contents of the specified URL. An optional parameter determines the format of the returned data.
Defined in: </ScriptBot/trunk/src/app/io.js>.
Defined in: </ScriptBot/trunk/src/app/io.js>.
- Parameters:
- {string} url
- The url/location to be fetched.
- {boolean} asLines Optional
truereturns the contents as a \n (new line) separated string,falseto return the contents as an array of lines.
- Since:
- 2.0.1
- Returns:
- A string or an Array containing the contents of the requested URL.
<static>
IO.fileExists(path)
Checks if the given file exists.
Defined in: </ScriptBot/trunk/src/app/io.js>.
Defined in: </ScriptBot/trunk/src/app/io.js>.
- Parameters:
- {string} path
- The path to the file being checked.
- Since:
- 2.0.3
- Returns:
trueif it exists,falseotherwise.
<static>
IO.include(path, relative)
Includes the given script file into the current runtime. An optional parameter describes whether the path is relative or absolute.
- Parameters:
- {string} path
- The path to the file.
- {string} relative Optional
trueif the path is relative to #path,falseif the path is absolute.
<static>
IO.objectExists(name)
Checks if the given object file exists.
Defined in: </ScriptBot/trunk/src/app/io.js>.
Defined in: </ScriptBot/trunk/src/app/io.js>.
- Parameters:
- {string} name
- The name of the object file being checked.
- Since:
- 2.0.3
- Returns:
trueif it exists,falseotherwise.
<static>
IO.readFile(path, asLines)
Reads in the specified file. Optionally returns the contents as a string or an array of lines.
Defined in: </ScriptBot/trunk/src/app/io.js>.
Defined in: </ScriptBot/trunk/src/app/io.js>.
- Parameters:
- {string} path
- The path to the file.
- {boolean} asLines
trueif the output should be returned as an array,falseif as a string.
- Since:
- 2.0.1
- Returns:
trueif the output should be returned as an array,falseif as a string.
<static>
{Object}
IO.readObject(name, funct)
Returns an object previously saved via #writeObject.
Defined in: </ScriptBot/trunk/src/app/io.js>.
Defined in: </ScriptBot/trunk/src/app/io.js>.
- Parameters:
- {string} name
- The name of the object to be read.
- {Function} funct
- A function used to modify the returned result. Consult JSON documentation.
- Since:
- 2.0.1
- Returns:
- an instance of the saved object if present; null if otherwise.
<static>
IO.writeFile(path, contents, append)
Writes the given contents to the specified path.
Defined in: </ScriptBot/trunk/src/app/io.js>.
Defined in: </ScriptBot/trunk/src/app/io.js>.
- Parameters:
- {string} path
- Path to the file to be written.
- {string} contents
- The contents of the file to be written.
- {boolean} append Optional
- Whether to append the given contents instead of overwriting.
- Since:
- 2.0.1
<static>
IO.writeObject(name, object, funct, tabin)
Writes the given object out to a file such that it can be read in via #readObject.
Similar to a "pretty printer" which formats an object so as to be easily viewed in the output window.
Note that all primivites will be wrapped in an array for output.
Defined in: </ScriptBot/trunk/src/app/io.js>.
Defined in: </ScriptBot/trunk/src/app/io.js>.
- Parameters:
- {string} name
- The name of the object to be saved, to be used when read back in.
- {object} object
- The object to be saved.
- {Function} funct Optional
- A function used to modify the output. Consult JSON documentation.
- {string} tabin Optional
- Used to specify the indentation used in output.
- Since:
- 2.0.1