At least in my test, it did not matter, writing data or an empty string.
writing undefined or nothing gives an error, but, surprise,surprise, a file is created. @fanoush, Data cannot be overwritten, thats a good point. I did not read this before.
BTW, try this:
st.write("a","",0,10);
=true
>st.read("a");
="\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
>st.readArrayBuffer("a");
=new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255, 255, 255]).buffer
>st.write("a","AB",0);
=true
>st.read("a")
="AB"
>st.readArrayBuffer("a");
=new Uint8Array([65, 66]).buffer
>st.write("a","CD",2);
Uncaught Error: Too much data for file size
at line 1 col 20
st.write("a","CD",2);
^
>st.write("a",[66,67],2);
Uncaught Error: Too much data for file size
at line 1 col 23
st.write("a",[66,67],2);
^
>st.read("a");
="AB"
>
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
At least in my test, it did not matter, writing data or an empty string.
writing undefined or nothing gives an error, but, surprise,surprise, a file is created.
@fanoush, Data cannot be overwritten, thats a good point. I did not read this before.
BTW, try this:
On the other hand, this works
Anyway, it works for me now ;-)