procedura

0

jego jedynym problemem jest to ze nie moge zapisac do pliku wartosci ktore on znajduje- w tym tkwi moj caly problem. Pomozcie.

unit Unit1;
interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TFileName = type string;
THandle = LongWord;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);

private
public
{ Public declarations }
end;
var
Form1: TForm1;

mplementation

{$R .dfm}
procedure SearchDir(StartPath: string);
type
TSearchRec = record
Time: Integer;
Size: Integer;
Attr: Integer;
Name: TFileName;
FindHandle: THandle;
FindData: TWin32FindData;
end ;
var
SR: TSearchRec;
Found : Integer;
i: Integer;
TF : TextFile;
function IsDir(Value : string) : string;
begin
if Value[Length(Value)] <> '' then
Result := Value + '' else Result := Value;
end;
begin
Found := FindFirst(IsDir(StartPath) + '
.*', faDirectory, SR);
while Found = 0 do
begin
Application.ProcessMessages;
if ((SR.Attr and faDirectory) = faDirectory) and ((SR.name <> '.') and (SR.name <> '..')) then
begin
SearchDir(IsDir(StartPath) + SR.name);
end
else
if ((SR.Attr and faDirectory) = 0) then
begin
if (AnsiLowerCase(ExtractFileExt(IsDir(StartPath) + SR.name)) = '.exe') then
end;
Found := FindNext(SR);
end;
begin
AssignFile (TF, 'c:/lista1.txt');
writeLn(TF, TSearchRec);
Rewrite (TF);
CloseFile(TF);
FindClose(SR);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SearchDir('c:\test');
end;
end.

0
Rewrite (TF); 
writeLn(TF, TSearchRec); 
CloseFile(TF); 

kolejnosc...

//kompilator?
//A tak przy okazji to moglbys jakos ten kod sformatowac...

0
Rewrite (TF); 
writeLn(TF, TSearchRec); 
CloseFile(TF); 

kolejnosc...

a to jednak nie to - nawet po zmianie kolejnosci kompilator sie tym krztusi
!

0

Ta.. w tagi < delphi > < /delphi > mógłbyś to najpierw ująć, bo ciężko się to czyta...
Ale tak popatrzyłęm na ten kod i się zastanaiwam co ty zapisujesz...:

TSearchRec = record
...
end ;
var
...
TF : TextFile;

a później ni stąd ni zowąd (jak to się pisze?!) do pliku tekstowego zapisujesz:

AssignFile (TF, 'c:/lista1.txt');
writeLn(TF, TSearchRec);
Rewrite (TF);
CloseFile(TF);

?! Pomijając już kolejność, (najpierw zapis potem [utworzenie], wyczyszczenie i otwarcie pliku) to do pliku tekstowego możesz zapisać tylko tekst, nie sądzisz? ;] No i oczywiście zapisuj zmienną typu TCostam a nie typ TCostam! Bo to jakaś paranoja ;)
Proponuję poczytać o plikach typowanych - myślę, że to rozwiąże Twój problem.

//Acha i taka mała rada - może zdradź nam chociaż, cóż za błędy wyskakują?

1 użytkowników online, w tym zalogowanych: 0, gości: 1