Hi,
Okay, I know how to write multiple lines into a file on the NXT, and it's proven very helpful in creating readable .txt datalogs. What my question is, is it possible for the NXT to retrieve information from a file in any of the written lines instead of just the last recorded line? And also, is it possible to accurately retrieve data from a .txt file? Thanks
Botmaster
Re: Reading from multiple lines in a File
Posted: 21 Dec 2010, 20:51
by mattallen37
Well, with NXC, Yes, and Yes.
Re: Reading from multiple lines in a File
Posted: 21 Dec 2010, 21:33
by muntoo
logebotmaster wrote:Hi,
What my question is, is it possible for the NXT to retrieve information from a file in any of the written lines instead of just the last recorded line?
Matt, I think that the OP was also asking "how".
Assuming it's in string format, you may want to check out ReadLnString().
Re: Reading from multiple lines in a File
Posted: 21 Dec 2010, 21:43
by muntoo
I can't edit my post...
Anyways, here it is again:
@Matt, I think that the OP was also asking "how".
logebotmaster wrote:Hi,
What my question is, is it possible for the NXT to retrieve information from a file in any of the written lines instead of just the last recorded line?
Assuming it's in string format, you may want to check out ReadLnString().
if(OpenFileRead("File.txt", size, handle) == NO_ERR)
{
until (Sdone == true) // read the text file till the end
{
if(ReadLnString(handle,message) != NO_ERR) Sdone = true;
//You need to grab the message and write it to another string(or whatever you need to do) all right here.
//Base it on an increasing variable, like the following lines.
TotalMessage[i]=message;
i++
}
}
if(OpenFileRead("File.txt", size, handle) == NO_ERR)
{
until (Sdone == true) // read the text file till the end
{
if(ReadLnString(handle,message) != NO_ERR) Sdone = true;
//You need to grab the message and write it to another string(or whatever you need to do) all right here.
//Base it on an increasing variable, like the following lines.
TotalMessage[i]=message;
i++
}
}
[/quote]
I need to write this to the variable "Sen". Can you modify this
program to do this?
And how does muntoo do the "Show" thing????
Re: Reading from multiple lines in a File
Posted: 22 Dec 2010, 00:42
by muntoo
dudmaster wrote:
I need to write this to the variable "Sen". Can you modify this
program to do this?
And how does muntoo do the "Show" thing????
One of these buttons contains the answer. Actually, they all do.
Anyways, enough fooling around before Xander gets tempted to remove the "Show button" . Here's what you want, assuming that Sen is an array of strings: