UNIT Unit1;
{$mode objfpc}{$H+}
INTERFACE
USES
Classes, Sysutils, Fileutil, Forms, Controls, Graphics, Dialogs, StdCtrls,
CheckLst, EditBtn, FileCtrl;
TYPE
{ Tform1 }
Tform1 = CLASS(Tform)
Button_Extract: Tbutton;
Button_Refresh: Tbutton;
Button_Quit: Tbutton;
CheckListBox1: TCheckListBox;
DirectoryEdit1: TDirectoryEdit;
FileListBox1: TFileListBox;
Memo1: Tmemo;
PROCEDURE Button_ExtractClick(Sender: Tobject);
PROCEDURE Button_RefreshClick(Sender: Tobject);
PROCEDURE Button_QuitClick(Sender: Tobject);
PROCEDURE DirectoryEdit1Change(Sender: Tobject);
PROCEDURE FormCreate(Sender: Tobject);
Private
Public
END;
VAR
Form1: Tform1;
IMPLEMENTATION
{$R *.lfm}
{ Tform1 }
PROCEDURE Tform1.FormCreate(Sender: Tobject);
BEGIN
DirectoryEdit1.Directory := 'C:\MP3_Dat_Test';
FileListBox1.Mask := '*.mp3';
FileListBox1.Directory := DirectoryEdit1.Directory;
CheckListBox1.Items := FileListBox1.Items;
FileListBox1.Visible := False;
END;
PROCEDURE Tform1.Button_QuitClick(Sender: Tobject);
BEGIN
CheckListBox1.Free;
Release;
Application.Terminate;
END;
PROCEDURE Tform1.DirectoryEdit1Change(Sender: Tobject);
BEGIN
FileListBox1.Directory := DirectoryEdit1.Directory;
CheckListBox1.Items := FileListBox1.Items;
END;
PROCEDURE Tform1.Button_RefreshClick(Sender: Tobject);
BEGIN
FileListBox1.UpdateFileList;
CheckListBox1.Items := FileListBox1.Items;
Memo1.Clear;
END;
PROCEDURE Tform1.Button_ExtractClick(Sender: Tobject);
VAR
MyBuffer : ARRAY[0..125] OF byte;
InputFile1, OutputFile1 : FILE;
Counter : Integer;
LocalCounter : Integer;
Line, Space : STRING;
NewLine : STRING;
TempFileName1 : STRING;
InputFile2, OutputFile2 : Text;
BEGIN
{Go thru the list of checkbox items, find the}
{one that is checked & process that file}
FOR LocalCounter := 0 TO CheckListBox1.Items.Count - 1 DO
BEGIN
IF CheckListBox1.Checked[LocalCounter] = True
THEN
BEGIN
Line := '';
TempFileName1 := DirectoryEdit1.Directory + '\' + CheckListBox1.Items.Strings[LocalCounter];
AssignFile(InputFile1, TempFileName1);
AssignFile(OutputFile1, 'C:\MP3_Dat_Test\Testout.dat');
Reset(InputFile1);
Rewrite(OutputFile1);
BlockRead(InputFile1, MyBuffer, 1);
BlockWrite(OutputFile1, MyBuffer, 1);
CloseFile(InputFile1);
CloseFile(OutputFile1);
AssignFile(OutputFile2, 'C:\MP3_Dat_Test\Testout.dat');
Append(OutputFile2);
WriteLn(OutputFile2, Chr(13));
WriteLn(OutputFile2, TempFileName1);
CloseFile(OutputFile2);
AssignFile(InputFile2, 'C:\MP3_Dat_Test\Testout.dat');
Reset(InputFile2);
ReadLn(InputFile2, Line);
NewLine := '';
Space := ' ';
{Go thru 'Line' and pull out the valid ASCII bytes}
BEGIN
FOR Counter := 1 TO 126 DO
IF (Line[Counter] >= #33) AND (Line[Counter] <= #126)
THEN NewLine := NewLine + Line[Counter];
END;
Memo1.Lines.AddStrings(NewLine);
Memo1.Lines.AddStrings(Space);
CloseFile(InputFile2);
END;
END;
END;
END.