Page 1 of 1

.TRACK Save Problems

Posted: 13 Mar 2011, 17:25
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

Re: .TRACK Save Problems

Posted: 13 Mar 2011, 17:42
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

Re: .TRACK Save Problems

Posted: 13 Mar 2011, 18:34
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

Re: .TRACK Save Problems

Posted: 13 Mar 2011, 20:56
by dudmaster
Now i'm using .TCK files. This apparently is where it freezes:

Code: Select all

Z = A[I];
(Not much, Eh?)