Текущий архив: 2003.09.11;
Скачать: CL | DM;
Вниз
Запись в файл Найти похожие ветки
← →
maker (2003-08-30 16:19) [0]Здравствуйте!
Подскажите как правильно записать массив данных в файл?
использую такой метод,
for i:=1 to CategoryList.Items.Count do
где
begin
o:=atEncode(CategoryList.Items.Strings[i-1]);
bb:=Length(CategoryList.Items.Strings[i-1]);
WriteFile(hFile,bb,sizeOf(Byte),Temp,nil);
WriteFile(hFile,Pointer(o)^,bb,Temp,nil);
end;
bb:byte;
o: array of byte;
hFile:THandle; //hFile:=CreateFile(..);
i:integer;
CategoryList - это ListBox;
Функция atEncode переводит символы в байты изменяя их значения (кодирование).
скажите, кто может - какие у меня ошибки?
← →
Tihomirov (2003-08-30 17:38) [1]В принципе StringGrid массив строк:
Procedure SaveKart(NFile: String);
Var
ProgramPath, NameFile2: String;
ActiveKatalog: String;
S1: String;
I1: Integer;
B1: Byte;
begin
ProgramPath:="";
GetDir(0,ActiveKatalog);
I1:=0;
I1:= Length (ActiveKatalog);
If Not (Copy (ActiveKatalog, I1,1) = "\") then
Begin
ProgramPath:=ActiveKatalog+"\";
end;
I1:=0;
ProgramPath:=ProgramPath+"Data\";
NameFile2:=ProgramPath+NFile;
AssignFile(File2, NameFile2);
{$I-}
reset(File2);
{$I+}
if IOResult <> 0 then
Begin
Rewrite (File2);
end
else
Begin
CloseFile(File2);
end;
Rewrite(File2);
{Сохранение}
Str(Dan.Zap,S1);
writeLn(File2,S1);
For I1:=1 to Dan.Zap do
For B1:=0 to 6 do
Begin
S1:=form1.StringGrid2.Cells[B1,I1];
writeLn(File2,S1);
end;
S1:=Form1.Label203.Caption;
writeLn(File2,S1);
CloseFile(File2);
end;
Procedure LoadKart(NFile: String);
Var
ProgramPath, NameFile2: String;
ActiveKatalog: String;
S1: String;
B1: Byte;
I1: Integer;
Code: Integer;
Begin
ProgramPath:="";
GetDir(0,ActiveKatalog);
I1:=0;
I1:= Length (ActiveKatalog);
If Not (Copy (ActiveKatalog, I1,1) = "\") then
Begin
ProgramPath:=ActiveKatalog+"\";
end;
I1:=0;
ProgramPath:=ProgramPath+"Data\";
NameFile2:=ProgramPath+NFile;
AssignFile(File2,NameFile2);
{$I-}
reset(File2);
{$I+}
if IOResult <> 0 then
Begin
// LoadOp:= False;
end
else
Begin
// LoadOp:=True;
Reset(File2);
Begin
S1:="";
{Загрузка}
ReadLn(File2,S1);
Val(S1,I1,Code);
Dan.Zap:=I1;
If Dan.Zap = 0 then
Form1.StringGrid2.RowCount:=2
else
Form1.StringGrid2.RowCount:= Dan.Zap+1;
Begin
For I1:=1 to Dan.Zap do
For B1:=0 to 6 do
Begin
ReadLn(File2,S1);
form1.StringGrid2.Cells[B1,I1]:=S1;
end;
end;
end;
ReadLn(File2,S1);
Form1.Label203.Caption:=S1;
CloseFile(File2);
end;
end;
Страницы: 1 вся ветка
Текущий архив: 2003.09.11;
Скачать: CL | DM;
Память: 0.45 MB
Время: 0.008 c