Skip to content

FileCSV

Hyomoto edited this page Nov 29, 2020 · 7 revisions
Jump To Go Back Arguments Methods Variables

FileCSV( filename, read_only?, new? )

Implements: File

Used for creating, reading and saving to CSV files. Files are written on a per-column basis, and you must use writeln() to advance to a new row. Reading is also on a per-column basis, and you can check if you have reached the end of the row by calling eol().

 // writing
var _csv = new FileCSV( "my.csv", true, true );

_csv.write( "Sword", 10, 10 );
_csv.writeln( "Armor", 20, 30 );

_csv.close();

 // reading
var _csv	= new FileCSV( "my.csv", true, false );

show_debug_message( _csv.read() );
// Sword
_csv.readln();
// Armor
show_debug_message( _csv.red() );

Arguments

Name Type Purpose
filename string the name of the file to open
read_only? bool optional: whether this file should allow writing to. Default: true
new? bool optional: whether this file should be blank. Default: false

Methods

Jump To top read readln write writeln eol save

read()

Returns: real (0.00), string ("string"), or undefined

Name Type Purpose
None

Reads the next value in the file, if it exists, otherwise returns undefined.


readln()

Returns: N/A undefined

Name Type Purpose
None

Advances the read position to the next line


write( values... )

Returns: N/A undefined

Name Type Purpose
values... mixed The values to write to the file

Writes value to the end of the file


writeln()

Returns: N/A undefined

Name Type Purpose
None

Starts a new line in the file.


eol()

Returns: boolean (true or false)

Name Type Purpose
None

Returns true if the end of the current line has been reached


save( append )

Returns: N/A undefined

Name Type Purpose
append bool Whether to append or rewrite the file.

Saves the file to disk. If append is true, entries will be appended after the last position the file was written from.


Variables

Jump To top
  • writeIndex - The point at which the file is currently being written to.
  • readIndex - The index at which the file is currently being read from.
Clone this wiki locally