sd.append()
sd.append(filename, data)
Appends a string to a file on the memory card, creating the file if needed.
Appends data to filename on the memory card. Convert numbers and objects
with string() first, and terminate lines with "\n" yourself.
Pair with datetime().epoch for timestamped log lines.
Arguments
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| filename | string | yes | — | File name on the memory card, e.g. "log.txt". |
| data | string | yes | — | Text to append. Use string() to convert numbers/objects. |
Returns
number
0 = no error, >0 = error code
Example
// Timestamped log line: 1589247811: ch3: 23.454
sd.append('log.txt', string(datetime().epoch) + ": ch3: " + string(23.454) + "\n");