Главная страница
    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.45 MB
Время: 0.008 c
3-33511
sash2
2003-08-19 22:15
2003.09.11
Проблема с переносом 2.


1-33634
lord
2003-08-30 22:36
2003.09.11
а что рекурсия в потоке не работает ?


4-33850
GuestTM
2003-07-09 05:31
2003.09.11
Непонятки с POSTMESSAGE


4-33846
sdram
2003-07-11 12:34
2003.09.11
Подскажите как прочитать переменную окружения


4-33844
Dimaxx
2003-07-11 23:05
2003.09.11
Как пользоваться функцией PickIconDlg?





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский