SpreadsheetRow
Package: Libraries.Interface.Controls.Support · Inherits from: Libraries.Language.Object
The SpreadsheetRow class is one line of a comma separated value (CSV) file as a Spreadsheet holds it: its values, how each value was written in the file, and how the line ended. A value read from a file keeps the exact text it had there, quotes and all, so the file can be written back unchanged. A value changed since reading forgets that text, and is written fresh. Rows can have different numbers of values, as lines of a file can; nothing is padded. SpreadsheetFile makes these rows, so most users won't need this class directly.
Example Code
use Libraries.Interface.Controls.Support.SpreadsheetRow
SpreadsheetRow row
row:AddValue(0, "Ada")
row:AddValue(1, "1815")
output row:GetValue(1)
Actions
AddReadValue(text value, text writtenText)
This action puts a value in at the given index with the exact text it had in a file. SpreadsheetFile uses it while reading.
Parameters
valuetext: The value.writtenTexttext: The value's text in the file, quotes and all.
Example
use Libraries.Interface.Controls.Support.SpreadsheetRow
SpreadsheetRow row
row:AddReadValue("Ada", "Ada")
AddValue(integer index, text value)
This action puts a value in at the given index, moving the values after it along by one. Past the end of the row, the row is padded first.
Parameters
indexinteger: Where the value goes, from 0.valuetext: The value.
Example
use Libraries.Interface.Controls.Support.SpreadsheetRow
SpreadsheetRow row
row:AddValue(0, "1815")
row:AddValue(0, "Ada")
output row:GetValue(0)
Copy()
This action returns a new row with the same values, written text and line ending, so a change to one doesn't change the other. Undo uses it.
Returns
Libraries.Interface.Controls.Support.SpreadsheetRow: The copy.
Example
use Libraries.Interface.Controls.Support.SpreadsheetRow
SpreadsheetRow row
row:AddValue(0, "Ada")
SpreadsheetRow other = row:Copy()
ForgetWritten(integer index)
This action forgets the file's text for one value, so it is written fresh the next time the row is saved. SpreadsheetFile uses it for a value that wasn't valid in the file.
Parameters
indexinteger: The index of the value, from 0.
GetLineEnding()
This action returns how the row's line ended in the file: a line feed, a carriage return and line feed, a carriage return, or "" for a last line with no line break.
Returns
text: The line ending.
Example
use Libraries.Interface.Controls.Support.SpreadsheetRow
SpreadsheetRow row
text ending = row:GetLineEnding()
GetSize()
This action returns how many values the row has. Rows can differ in length.
Returns
integer: The number of values in the row.
Example
use Libraries.Interface.Controls.Support.SpreadsheetRow
SpreadsheetRow row
row:AddValue(0, "Ada")
output row:GetSize()
GetValue(integer index)
This action returns the value at the given index, or "" if the row has no value there.
Parameters
indexinteger: The index of the value, from 0.
Returns
text: The value, or "" past the end of the row.
Example
use Libraries.Interface.Controls.Support.SpreadsheetRow
SpreadsheetRow row
row:AddValue(0, "Ada")
output row:GetValue(0)
GetWritten(integer index)
This action returns the value's text as it was in the file, or undefined if the value was changed since it was read.
Parameters
indexinteger: The index of the value, from 0.
Returns
text: The text from the file, or undefined.
Example
use Libraries.Interface.Controls.Support.SpreadsheetRow
SpreadsheetRow row
row:AddReadValue("Ada", "Ada")
output row:GetWritten(0)
RemoveValueAt(integer index)
This action removes the value at the given index, moving the values after it back by one. An index past the end of the row does nothing.
Parameters
indexinteger: The index of the value, from 0.
Example
use Libraries.Interface.Controls.Support.SpreadsheetRow
SpreadsheetRow row
row:AddValue(0, "Ada")
row:RemoveValueAt(0)
SetLineEnding(text ending)
This action sets how the row's line ends when it is written.
Parameters
endingtext: The line ending, or "" for none.
Example
use Libraries.Interface.Controls.Support.SpreadsheetRow
SpreadsheetRow row
text value = ""
row:SetLineEnding(value:GetLineFeed())
SetValue(integer index, text value)
This action sets the value at the given index. If the row is shorter, it is first padded with empty values. The value's text from the file is forgotten, so it is written fresh.
Parameters
indexinteger: The index of the value, from 0.valuetext: The new value.
Example
use Libraries.Interface.Controls.Support.SpreadsheetRow
SpreadsheetRow row
row:SetValue(2, "1815")
output row:GetSize()