.TRACK Save Problems

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
dudmaster
Posts: 171
Joined: 06 Oct 2010, 02:38
Location: Texas, Santa Fe
Contact:

.TRACK Save Problems

Post by dudmaster »

Hello, It's me again. (Have I asked enough? I just want to learn.)

I am having problems with the following code:

Code: Select all

void Track(int A[], string Name, int Octave)
{
int I = 0, Z;
string Doc, T, X = ",";
until (A[I] == 0)
{
Z = A[I];
T = NumToStr(Z);
StrCat(Doc, Doc, T, X);
I++;
}
byte handle;
Name = Name + ".track";
DeleteFile(Name);
CreateFile(Name, 300, handle);
int c = 0;
WriteLnString(handle, Doc, c);
CloseFile(handle);
}
What It's supposed to do:
When used, it saves a .track file with numbers in an array with commas separating them. (So the computer knows what to read)

What It does:
it freezes the NXT, so you have to take the batteries out.

THX,
Dud - 2Labz
2Labz.com, My Website
gloomyandy
Posts: 323
Joined: 29 Sep 2010, 05:03

Re: .TRACK Save Problems

Post by gloomyandy »

Hi,
How many elements are in the array? Have you tried the same code with only one or two elements?. What happens if you selectively remove parts of your code? Can you narrow down which part is causing the brick to lock up?

Andy
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: .TRACK Save Problems

Post by afanofosc »

I would not use file extensions longer than 3 characters. The firmware isn't really written to expect filenames with longer extensions.

The StrCat function takes input strings as its parameters and returns the concatenated string as its result. I think you want

Doc = StrCat(Doc, T, X);

In order to pinpoint where the problem is occurring you might want to add some TextOut or NumOut calls so you can tell how far the code executes before the brick locks up.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
dudmaster
Posts: 171
Joined: 06 Oct 2010, 02:38
Location: Texas, Santa Fe
Contact:

Re: .TRACK Save Problems

Post by dudmaster »

Now i'm using .TCK files. This apparently is where it freezes:

Code: Select all

Z = A[I];
(Not much, Eh?)
2Labz.com, My Website
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 1 guest