Author Topic: Reading, Writing text files in ML  (Read 3153 times)


  • Just arrived
  • *
  • Posts: 1
Reading, Writing text files in ML
« on: February 11, 2017, 07:51:20 AM »

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.



  • Administrator
  • Hero Member
  • *****
  • Posts: 12564
Re: Reading, Writing text files in ML
« Reply #1 on: February 11, 2017, 09:20:21 AM »
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).