I've attached a copy of the file I'm trying to import. I've renamed it to a .TXT so that EE will allow me to attach it, but it's not a text file.
The attached code was used to create this file, and I'd like to come up with similar code that will allow me to import the file back into the program.
I'm just not a File I/O guy. I need some help, preferably a solution that uses FileOpen() and FileRead() to get it done.
The first 4 bytes of this file are 06 00 00 00, and they represent an integer, 6. The second 4 bytes are 7C 02 00 00, which represent the number 636. The remainder of the file contains 3,816 values (6x636).
The first "value" is a 1, and it's stored as a 4-byte length (01 00 00 00) and the ascii value of the digit "1", (31)
The second value is another 5 bytes .. 01 00 00 00 31 .. this is another "1"
The third value is also 5 bytes.. 01 00 00 00 32 .. this represents a "2"
..hopefully this is clear. I'm sure you can figure out the data layout by looking at the ::ExportPicks() method.
Can someone write for me the body of this method?
void __fastcall TMyForm::ImportPicks(AnsiS
tring sFile, TStringGrid *pGrid)
/* help */
Thanks in advance...
void __fastcall TMyForm::ExportPicks(AnsiString sFile, TStringGrid *pGrid)
int iHandle = FileCreate(sFile);
int iLength = 0;
FileWrite(iHandle, (char*)&(pGrid->ColCount), sizeof(pGrid->ColCount));
FileWrite(iHandle, (char*)&(pGrid->RowCount), sizeof(pGrid->RowCount));
for (int y=0; y<pGrid->RowCount; y++)
for (int x=0; x<pGrid->ColCount; x++)
// Write out the length of each string, followed by the string itself.
iLength = pGrid->Cells[x][y].Length();
FileWrite(iHandle, (char*)&iLength, sizeof(iLength));
FileWrite(iHandle, pGrid->Cells[x][y].c_str(), pGrid->Cells[x][y].Length());