Pages: [1]   Go Down
Author Topic: Feature request: readln() in SD library  (Read 1424 times)
0 Members and 1 Guest are viewing this topic.
Norway
Offline Offline
Full Member
***
Karma: 0
Posts: 104
Have you thought it over before asking?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Feature request: readln() in SD library

What it would be doing: read a single line from a file as string.

It would be handy to have this as part of the SD library.

Because i am a beginner on C++ i cannot do this myself.

Logged

2B || !2B

... bonding electrons and bits!

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 217
Posts: 13739
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Because i am a beginner on C++ i cannot do this myself.
Maybe it is difficult, but you should be able to do it, there are many things in life that are much harder. Don't be afraid of failure as it is the best teacher there is.

Lets go to the requirements first.
Quote
What it would be doing: read a single line from a file as string.

The most important questions are:
* where to start
* when to stop

The second point is most difficult as there can be 2 conditions when to stop
1) You detected end of line
2) The string buffer is full.

This gives the additional question, how do we know it succeeded or failed?

And yes, how do you want to handle the end of line character?
1) included in the string
2) not included in the string

That are a lot of questions to be answered, but none is very difficult.

Given the above information, how would a call to the readln function look like?
What parameters does it have?
What return value(s)?
Can you provide three as real as possible calls to the readln() ?
1) that works OK,
2) where a buffer full error is encountered
3) reading an empty line from file

Succes,
Rob

John Fitzgerald Kennedy: We will go to the moon. We will go to the moon and do other things, NOT because they are easy but because they are HARD.
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: