TextLogger.append Member
Append data (an array or single item) to the file
Syntax
object.append(data);
Arguments
Argument | Summary |
---|---|
data |
Returns
Remarks
See Also
Source Code
function tl_append(data)
{
if (!isinstance(data, Array))
data = [data];
// If we go over the limit, don't write everything twice:
if ((this.autoLimit != -1) &&
(data.length + this.appended > this.autoLimit))
{
// Collect complete set of data instead:
var dataInFile = this.read();
var newData = dataInFile.concat(data);
// Get the last |autoLimit| items: yay JS negative indexing!
newData = newData.slice(-this.autoLimit);
this.limit(newData);
return true;
}
var file = fopen(this.path, ">>");
for (var i = 0; i < data.length; i++)
file.write(ecmaEscape(data[i]) + "\n");
file.close();
this.appended += data.length;
return true;
}