{TO-DO - What if I don't call .Free() on a .Create() stuff? Memory leak, or gets destroyed after function returns? - FTP } unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, OleCtrls, ExtCtrls, StrUtils; type TForm1 = class(TForm) ListBox1: TListBox; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation uses RegExpr; const inputdir : String = '.\input\'; templatesdir : String = '.\templates\'; outputdir : String = '.\output\'; datafile : String = '.\data.txt'; {$R *.dfm} //======================================================================== {function GetFileDate(TheFileName: string): string; var f: integer; begin f := FileOpen(TheFileName, 0); try //Result := DateTimeToStr(FileDateToDateTime(FileGetDate(f))); Result := DateToStr(FileDateToDateTime(FileGetDate(f))); finally FileClose(f); end; end;} function GetFileDate(TheFileName: string): TDateTime; var f: integer; begin f := FileOpen(TheFileName, 0); try Result := FileDateToDateTime(FileGetDate(f)); finally FileClose(f); end; end; procedure WriteFile (const MyFile: String; const MyStuff: String); var MyFileHdl : TextFile; begin AssignFile(MyFileHdl, MyFile); ReWrite(MyFileHdl); Write(MyFileHdl,MyStuff); CloseFile(MyFileHdl); end; { procedure ReadFileStream(const MyFile: String); var TempStream : TMemoryStream; MyStuff : String; begin TempStream := TMemoryStream.Create; MyStuff := LoadFromStream(TempStream); TempStream.Free; end; } function ReadFile (const MyFile: String): String; var MyFileHdl : TextFile; MyStuff : String; text : String; begin AssignFile(MyFileHdl, MyFile); Reset(MyFileHdl); while not Eof(MyFileHdl) do begin ReadLn(MyFileHdl, text); MyStuff := MyStuff + text + #13#10; end; CloseFile(MyFileHdl); Result := MyStuff; end; //======================================================================== procedure TForm1.Button1Click(Sender: TObject); const running : Boolean = False; //True = Already clicked var searchResult : TSearchRec; MyHeader : String; MyFooter : String; MyArticle : String; MyStuff : String; MyTitle : String; MyIndexB4 : String; MyIndexAfter : String; subdirectories : TStringList; i : Integer; OrigDate : TDateTime; CurrentDate : TDateTime; f: integer; filedata : TStringList; MyKeywords : String; MyClassification : String; MyFile : String; indexclassifications : TStringList; data : TStringList; LastModified : String; begin {MyHeader := ReadFile(templatesdir + 'header.html'); //Change TITLE in header.html to actual TITLE for this document MyTitle := 'coucou'; MyStuff := '