file.write

Syntax

b = file.write(a<,l>)
file.write(<f>) = l

Write a list to a file.

If a file pointer is not provided, then writes to the last opened file.

If called on get, then a list must be provided as an argument (after any optional file pointer). All entries in that list are written to the file. true is returned.

If called on assignment, then the assignment value is assumed to be a list that is written to the file.

Returns:

b - true

Accepts:

l - A list to write to the file

Arguments:

a - An optional file pointer indicating what file to write to. l - A list argument when called on get only that is written to the file.

Usage Example

The following example illustrates how file.write can be used

model new
zone create brick size 2 2 2
fish define output_gps
    local f = file.open("gps.txt","write","text")
    local l = list
    loop foreach local g gp.list
        local a = string.build("%1,%2,%3,%4", gp.id(g), ...
                       gp.pos(g)->x, gp.pos(g)->y, gp.pos(g)->z)
        l = list.append(l,a)
    endloop
    file.write(f,l)
    file.close(f)
end
[output_gps]