Report Bugs Here

Moderator: Mmiscool

User avatar
By cesare57
#48713 hello, i'm trying to use the read istruction , but i can't reat anyelse : the destinatin variabile , after executing istruction , is empty ( len(buffer) = 0 ) :

InfoP="/uploads/Pag1.txt"
print InfoP
READ InfoP testoPag$
print len(testoPag$)

i'm using branch 2.0

there's some error ? .. there is another way to read a file (I need to read a buffer to send it lo oled display , for a variety of page)
User avatar
By Mmiscool
#48735 Rename your file to "/data/Pag1.dat" by selecting the file from the file manager and clicking rename.

when using the read command

Code: Select allread "Pag1" testoPag$


The read command will read the first line of text from the file. It really is intended for storing a single variable.

To create one of these files you can also use the write command.

These data elements were only intended for storing the contents of a single variable for later. Not for general purpose file I/O.

I might also suggest using the word() function if you need to place multiple values in to a single file. This will allow you to parse out individual bits of data from a large string.
User avatar
By forlotto
#48912 Mark this to add to documentation.

Might want to address this as you did here in the documentation well done mmiscool this way people don't get the wrong idea of reads intended purpose and it will help things a bit via this great example and great question as well.