Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 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.47 MB
Время: 0.025 c
1-33625
Анастасия
2003-08-31 22:22
2003.09.11
Снова про Word


1-33662
tgdgdfg
2003-08-30 00:02
2003.09.11
Вопрос по TreeView для профессионалов!


1-33639
isff
2003-08-31 11:52
2003.09.11
Динамический вызов dll


3-33502
VladimirS
2003-08-19 07:35
2003.09.11
ExpressQuantumGrid


7-33821
Pauk
2003-06-26 19:11
2003.09.11
Принтеры