Reading, Writing text files in ML

Started by votality, February 11, 2017, 07:51:20 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

votality

Hi,

I want to be able to read a textfile from My SD card line by line, change a line and save it in ML.

Can someone pretty please provide a simple example to read, write (create) and modify text files with ML.

Last time i tried was a year ago, and from memory the biggest issue i had was it seems you cant use normal string libraries.


Thanks

a1ex

Easy: use a Lua script (the io functions should just work). See api_test for examples.

Fastest: read the entire file in memory (read_entire_file, which also allocates memory for you), but you need to do the line-based processing from scratch (see examples in config.c, menu.c). Ugly.

C string functions can be used, just add them to Makefile.src.config at the end (so they will be taken from dietlibc). You can also include the missing libc functions in a module (Lua does that).