View previous topic :: View next topic |
Author |
Message |
nicofer
Joined: 01 May 2013 Posts: 90 Location: GRJ
|
Posted: Thu Jan 23, 2014 8:52 am Post subject: LINEINPUT |
|
|
Hi
I want to perform a LINEINPUT from a text file - data saved by print command - but not from the first line but from the LAST line of the file
and then the 2nd last and so on , use of UP DOWN options to select line to read and display but starting from the latest saved line .
Plan is to display last entries in a LOG file on a LCD .
Any ideas on how to do this ?
Cheers
Nico
(BASCOM-AVR version : 2.0.7.6 ) |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Fri Jan 24, 2014 2:37 pm Post subject: |
|
|
Hi,
Why not use LOF to find the length of the file, seek to the end of the file then use get to read the last character. Seek to move back until you find the end of the second to last line. You now have the start/end of the last line which you can then print.
So have a look at get, seek, lof in the help text.
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
nicofer
Joined: 01 May 2013 Posts: 90 Location: GRJ
|
Posted: Mon Jan 27, 2014 7:27 am Post subject: |
|
|
Hi Ian
Yes , that is what I had in mind - I must just make sure about the seek and get and what they offer.
The other plan was to make all the entries a fixed length , then go same route from the EOF , almost like a big array , but I do not want to make it fixed if there is a other option.
Else if each entry is max 80 char then I can get EOF - then start reading it from EOF - 80 and search for first char after CR LF .
Please confirm - what is end of string terminator in the file .
Thanks for the reply
Cheers |
|
Back to top |
|
|
nicofer
Joined: 01 May 2013 Posts: 90 Location: GRJ
|
Posted: Mon Jan 27, 2014 8:02 am Post subject: |
|
|
I have another question
Is there a way to "load " the LINEINPUT data, to force it not to start from the beginning of a file , that you know about ?
I notice r24 is the file pointer and r25 is the string length .
I want to read from a file - and close it after each read / or after a timeout of no user input to prevent file errors due to external inputs , then next time I open the file to read the next line it will start from the first line again - I need to save the last line read location and then start the LINEINPUT from a pre-set position.
I will try the LOF - get seek route , but by injecting the correct parameters into the LINEINPUT function it might work .
There might be internal compiler values that one can read and write but I have no idea where to look for it.
Cheers |
|
Back to top |
|
|
|