codepageconverter example allowsnow to select files

git-svn-id: trunk@7606 -
This commit is contained in:
mattias 2005-08-31 07:51:07 +00:00
parent 8bcd2298e6
commit 3029bd9362
7 changed files with 136 additions and 315 deletions

View File

@ -7,5 +7,4 @@
198
230
208
240
240

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="/"/>
<PathDelim Value="\"/>
<Version Value="5"/>
<General>
<Flags>
@ -9,10 +9,10 @@
<SaveOnlyProjectUnits Value="True"/>
</Flags>
<MainUnit Value="0"/>
<ActiveEditorIndexAtStart Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=""/>
<Title Value="lazconverter"/>
<ActiveEditorIndexAtStart Value="0"/>
</General>
<Units Count="2">
<Unit0>
@ -21,31 +21,31 @@
<IsPartOfProject Value="True"/>
<TopLine Value="1"/>
<UnitName Value="lazconverter"/>
<UsageCount Value="32"/>
<UsageCount Value="36"/>
</Unit0>
<Unit1>
<CursorPos X="23" Y="61"/>
<CursorPos X="1" Y="286"/>
<EditorIndex Value="0"/>
<Filename Value="mainunit.pas"/>
<ComponentName Value="LazConverterForm"/>
<IsPartOfProject Value="True"/>
<Loaded Value="True"/>
<ResourceFilename Value="mainunit.lrs"/>
<TopLine Value="47"/>
<TopLine Value="109"/>
<UnitName Value="mainunit"/>
<UsageCount Value="32"/>
<UsageCount Value="36"/>
</Unit1>
</Units>
<PublishOptions>
<Version Value="2"/>
<DestinationDirectory Value="/home/barko/tempo/out/"/>
<DestinationDirectory Value="\home\barko\tempo\out\"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="2">
@ -60,8 +60,9 @@
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
<PathDelim Value="\"/>
<SearchPaths>
<SrcPath Value="$(LazarusDir)/lcl/;$(LazarusDir)/lcl/interfaces/$(LCLWidgetType)/"/>
<SrcPath Value="$(LazarusDir)\lcl\;$(LazarusDir)\lcl\interfaces\$(LCLWidgetType)\"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>

View File

@ -1,26 +1,27 @@
object LazConverterForm: TLazConverterForm
Caption = 'Codepage LazConverter for PAS, LFM, LRS & INC files v0.0.5'
Caption = 'Codepage LazConverter for PAS, LFM, LRS, LRT & INC files v0.0.6'
ClientHeight = 463
ClientWidth = 612
ClientWidth = 578
Constraints.MinHeight = 463
Constraints.MinWidth = 578
OnShow = Form1Show
PixelsPerInch = 95
PixelsPerInch = 96
Position = poScreenCenter
HorzScrollBar.Page = 611
HorzScrollBar.Page = 577
VertScrollBar.Page = 462
Left = 322
Left = 286
Height = 463
Top = 225
Width = 612
Top = 118
Width = 578
object Panel1: TPanel
Align = alTop
BorderSpacing.OnChange = nil
ClientHeight = 192
ClientWidth = 612
ClientHeight = 200
ClientWidth = 578
FullRepaint = False
TabOrder = 0
Height = 192
Width = 612
Height = 200
Width = 578
object Label1: TLabel
BorderSpacing.OnChange = nil
Caption = 'Path to your project:'
@ -56,7 +57,7 @@ object LazConverterForm: TLazConverterForm
Left = 8
Height = 17
Top = 149
Width = 593
Width = 559
end
object Edit1: TEdit
Anchors = [akTop, akLeft, akRight]
@ -65,7 +66,7 @@ object LazConverterForm: TLazConverterForm
Left = 8
Height = 23
Top = 32
Width = 513
Width = 479
end
object Button1: TButton
Anchors = [akTop, akRight]
@ -73,7 +74,7 @@ object LazConverterForm: TLazConverterForm
Caption = 'Path'
OnClick = Button1Click
TabOrder = 1
Left = 530
Left = 496
Height = 23
Top = 32
Width = 75
@ -81,36 +82,26 @@ object LazConverterForm: TLazConverterForm
object ComboBox1: TComboBox
BorderSpacing.OnChange = nil
MaxLength = 0
TabOrder = 3
TabOrder = 2
Left = 8
Height = 25
Height = 21
Top = 80
Width = 200
end
object ComboBox2: TComboBox
BorderSpacing.OnChange = nil
MaxLength = 0
TabOrder = 6
TabOrder = 5
Left = 216
Height = 25
Height = 21
Top = 80
Width = 200
end
object CheckBox1: TCheckBox
AllowGrayed = True
BorderSpacing.OnChange = nil
Caption = 'Include subdirectories'
TabOrder = 2
Left = 424
Height = 23
Top = 80
Width = 176
end
object Button2: TButton
BorderSpacing.OnChange = nil
Caption = 'Search'
OnClick = Button2Click
TabOrder = 4
TabOrder = 3
Left = 8
Height = 25
Top = 112
@ -120,7 +111,7 @@ object LazConverterForm: TLazConverterForm
BorderSpacing.OnChange = nil
Caption = 'Convert'
OnClick = Button3Click
TabOrder = 5
TabOrder = 4
Left = 88
Height = 25
Top = 112
@ -130,24 +121,21 @@ object LazConverterForm: TLazConverterForm
Align = alBottom
BorderSpacing.OnChange = nil
Max = 100
TabOrder = 7
TabOrder = 6
TabStop = True
Left = 1
Height = 17
Top = 174
Width = 610
Top = 182
Width = 576
end
end
object Memo1: TMemo
Align = alBottom
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.OnChange = nil
ReadOnly = True
object FileListBox1: TFileListBox
Align = alClient
PopupMenu = PopupMenu1
TabOrder = 1
WordWrap = False
Height = 263
Top = 200
Width = 612
Width = 578
end
object SelectDirectoryDialog1: TSelectDirectoryDialog
Title = 'Select Directory'
@ -156,4 +144,12 @@ object LazConverterForm: TLazConverterForm
left = 8
top = 480
end
object PopupMenu1: TPopupMenu
left = 272
top = 123
object MenuItem1: TMenuItem
Caption = 'Remove from conversion'
OnClick = MenuItem1Click
end
end
end

View File

@ -1,46 +1,45 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TLazConverterForm','FORMDATA',[
'TPF0'#17'TLazConverterForm'#16'LazConverterForm'#7'Caption'#6':Codepage LazC'
+'onverter for PAS, LFM, LRS & INC files v0.0.5'#12'ClientHeight'#3#207#1#11
+'ClientWidth'#3'd'#2#21'Constraints.MinHeight'#3#207#1#20'Constraints.MinWid'
+'th'#3'B'#2#6'OnShow'#7#9'Form1Show'#13'PixelsPerInch'#2'_'#8'Position'#7#14
+'poScreenCenter'#18'HorzScrollBar.Page'#3'c'#2#18'VertScrollBar.Page'#3#206#1
+#4'Left'#3'B'#1#6'Height'#3#207#1#3'Top'#3#225#0#5'Width'#3'd'#2#0#6'TPanel'
+#6'Panel1'#22'BorderSpacing.OnChange'#13#12'ClientHeight'#3#192#0#11'ClientW'
+'idth'#3'd'#2#11'FullRepaint'#8#8'TabOrder'#2#0#6'Height'#3#192#0#5'Width'#3
+'d'#2#0#6'TLabel'#6'Label1'#22'BorderSpacing.OnChange'#13#7'Caption'#6#21'Pa'
+'th to your project:'#5'Color'#7#6'clNone'#4'Left'#2#8#6'Height'#2#19#3'Top'
+#2#16#5'Width'#3#168#0#0#0#6'TLabel'#6'Label2'#22'BorderSpacing.OnChange'#13
+#7'Caption'#6#13'Convert From:'#5'Color'#7#6'clNone'#4'Left'#2#8#6'Height'#2
+#15#3'Top'#2'@'#5'Width'#3#159#0#0#0#6'TLabel'#6'Label3'#22'BorderSpacing.On'
+'Change'#13#7'Caption'#6#11'Convert To:'#5'Color'#7#6'clNone'#4'Left'#3#216#0
+#6'Height'#2#15#3'Top'#2'@'#5'Width'#2'{'#0#0#6'TLabel'#6'Label6'#7'Anchors'
+#11#5'akTop'#6'akLeft'#7'akRight'#0#22'BorderSpacing.OnChange'#13#7'Caption'
+#6#8'Ready...'#5'Color'#7#6'clNone'#4'Left'#2#8#6'Height'#2#17#3'Top'#3#149#0
+#5'Width'#3'Q'#2#0#0#5'TEdit'#5'Edit1'#7'Anchors'#11#5'akTop'#6'akLeft'#7'ak'
+'Right'#0#22'BorderSpacing.OnChange'#13#8'TabOrder'#2#0#4'Left'#2#8#6'Height'
+#2#23#3'Top'#2' '#5'Width'#3#1#2#0#0#7'TButton'#7'Button1'#7'Anchors'#11#5'a'
+'kTop'#7'akRight'#0#22'BorderSpacing.OnChange'#13#7'Caption'#6#4'Path'#7'OnC'
+'lick'#7#12'Button1Click'#8'TabOrder'#2#1#4'Left'#3#18#2#6'Height'#2#23#3'To'
+'p'#2' '#5'Width'#2'K'#0#0#9'TComboBox'#9'ComboBox1'#22'BorderSpacing.OnChan'
+'ge'#13#9'MaxLength'#2#0#8'TabOrder'#2#3#4'Left'#2#8#6'Height'#2#25#3'Top'#2
+'P'#5'Width'#3#200#0#0#0#9'TComboBox'#9'ComboBox2'#22'BorderSpacing.OnChange'
+#13#9'MaxLength'#2#0#8'TabOrder'#2#6#4'Left'#3#216#0#6'Height'#2#25#3'Top'#2
+'P'#5'Width'#3#200#0#0#0#9'TCheckBox'#9'CheckBox1'#11'AllowGrayed'#9#22'Bord'
+'erSpacing.OnChange'#13#7'Caption'#6#22'Include subdirectories'#8'TabOrder'#2
+#2#4'Left'#3#168#1#6'Height'#2#23#3'Top'#2'P'#5'Width'#3#176#0#0#0#7'TButton'
+#7'Button2'#22'BorderSpacing.OnChange'#13#7'Caption'#6#6'Search'#7'OnClick'#7
+#12'Button2Click'#8'TabOrder'#2#4#4'Left'#2#8#6'Height'#2#25#3'Top'#2'p'#5'W'
+'idth'#2'K'#0#0#7'TButton'#7'Button3'#22'BorderSpacing.OnChange'#13#7'Captio'
+'n'#6#7'Convert'#7'OnClick'#7#12'Button3Click'#8'TabOrder'#2#5#4'Left'#2'X'#6
+'Height'#2#25#3'Top'#2'p'#5'Width'#2'{'#0#0#12'TProgressBar'#12'ProgressBar1'
+#5'Align'#7#8'alBottom'#22'BorderSpacing.OnChange'#13#3'Max'#2'd'#8'TabOrder'
+#2#7#7'TabStop'#9#4'Left'#2#1#6'Height'#2#17#3'Top'#3#174#0#5'Width'#3'b'#2#0
+#0#0#5'TMemo'#5'Memo1'#5'Align'#7#8'alBottom'#7'Anchors'#11#5'akTop'#6'akLef'
+'t'#7'akRight'#8'akBottom'#0#22'BorderSpacing.OnChange'#13#8'ReadOnly'#9#8'T'
+'abOrder'#2#1#8'WordWrap'#8#6'Height'#3#7#1#3'Top'#3#200#0#5'Width'#3'd'#2#0
+#0#22'TSelectDirectoryDialog'#22'SelectDirectoryDialog1'#5'Title'#6#16'Selec'
+'t Directory'#11'FilterIndex'#2#0#5'Title'#6#16'Select Directory'#4'left'#2#8
+#3'top'#3#224#1#0#0#0
'TPF0'#17'TLazConverterForm'#16'LazConverterForm'#7'Caption'#6'?Codepage LazC'
+'onverter for PAS, LFM, LRS, LRT & INC files v0.0.6'#12'ClientHeight'#3#207#1
+#11'ClientWidth'#3'B'#2#21'Constraints.MinHeight'#3#207#1#20'Constraints.Min'
+'Width'#3'B'#2#6'OnShow'#7#9'Form1Show'#13'PixelsPerInch'#2'`'#8'Position'#7
+#14'poScreenCenter'#18'HorzScrollBar.Page'#3'A'#2#18'VertScrollBar.Page'#3
+#206#1#4'Left'#3#30#1#6'Height'#3#207#1#3'Top'#2'v'#5'Width'#3'B'#2#0#6'TPan'
+'el'#6'Panel1'#5'Align'#7#5'alTop'#22'BorderSpacing.OnChange'#13#12'ClientHe'
+'ight'#3#200#0#11'ClientWidth'#3'B'#2#11'FullRepaint'#8#8'TabOrder'#2#0#6'He'
+'ight'#3#200#0#5'Width'#3'B'#2#0#6'TLabel'#6'Label1'#22'BorderSpacing.OnChan'
+'ge'#13#7'Caption'#6#21'Path to your project:'#5'Color'#7#6'clNone'#4'Left'#2
+#8#6'Height'#2#19#3'Top'#2#16#5'Width'#3#168#0#0#0#6'TLabel'#6'Label2'#22'Bo'
+'rderSpacing.OnChange'#13#7'Caption'#6#13'Convert From:'#5'Color'#7#6'clNone'
+#4'Left'#2#8#6'Height'#2#15#3'Top'#2'@'#5'Width'#3#159#0#0#0#6'TLabel'#6'Lab'
+'el3'#22'BorderSpacing.OnChange'#13#7'Caption'#6#11'Convert To:'#5'Color'#7#6
+'clNone'#4'Left'#3#216#0#6'Height'#2#15#3'Top'#2'@'#5'Width'#2'{'#0#0#6'TLab'
+'el'#6'Label6'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#22'BorderSpacin'
+'g.OnChange'#13#7'Caption'#6#8'Ready...'#5'Color'#7#6'clNone'#4'Left'#2#8#6
+'Height'#2#17#3'Top'#3#149#0#5'Width'#3'/'#2#0#0#5'TEdit'#5'Edit1'#7'Anchors'
+#11#5'akTop'#6'akLeft'#7'akRight'#0#22'BorderSpacing.OnChange'#13#8'TabOrder'
+#2#0#4'Left'#2#8#6'Height'#2#23#3'Top'#2' '#5'Width'#3#223#1#0#0#7'TButton'#7
+'Button1'#7'Anchors'#11#5'akTop'#7'akRight'#0#22'BorderSpacing.OnChange'#13#7
+'Caption'#6#4'Path'#7'OnClick'#7#12'Button1Click'#8'TabOrder'#2#1#4'Left'#3
+#240#1#6'Height'#2#23#3'Top'#2' '#5'Width'#2'K'#0#0#9'TComboBox'#9'ComboBox1'
+#22'BorderSpacing.OnChange'#13#9'MaxLength'#2#0#8'TabOrder'#2#2#4'Left'#2#8#6
+'Height'#2#21#3'Top'#2'P'#5'Width'#3#200#0#0#0#9'TComboBox'#9'ComboBox2'#22
+'BorderSpacing.OnChange'#13#9'MaxLength'#2#0#8'TabOrder'#2#5#4'Left'#3#216#0
+#6'Height'#2#21#3'Top'#2'P'#5'Width'#3#200#0#0#0#7'TButton'#7'Button2'#22'Bo'
+'rderSpacing.OnChange'#13#7'Caption'#6#6'Search'#7'OnClick'#7#12'Button2Clic'
+'k'#8'TabOrder'#2#3#4'Left'#2#8#6'Height'#2#25#3'Top'#2'p'#5'Width'#2'K'#0#0
+#7'TButton'#7'Button3'#22'BorderSpacing.OnChange'#13#7'Caption'#6#7'Convert'
+#7'OnClick'#7#12'Button3Click'#8'TabOrder'#2#4#4'Left'#2'X'#6'Height'#2#25#3
+'Top'#2'p'#5'Width'#2'{'#0#0#12'TProgressBar'#12'ProgressBar1'#5'Align'#7#8
+'alBottom'#22'BorderSpacing.OnChange'#13#3'Max'#2'd'#8'TabOrder'#2#6#7'TabSt'
+'op'#9#4'Left'#2#1#6'Height'#2#17#3'Top'#3#182#0#5'Width'#3'@'#2#0#0#0#12'TF'
+'ileListBox'#12'FileListBox1'#5'Align'#7#8'alClient'#9'PopupMenu'#7#10'Popup'
+'Menu1'#8'TabOrder'#2#1#6'Height'#3#7#1#3'Top'#3#200#0#5'Width'#3'B'#2#0#0#22
+'TSelectDirectoryDialog'#22'SelectDirectoryDialog1'#5'Title'#6#16'Select Dir'
+'ectory'#11'FilterIndex'#2#0#5'Title'#6#16'Select Directory'#4'left'#2#8#3't'
+'op'#3#224#1#0#0#10'TPopupMenu'#10'PopupMenu1'#4'left'#3#16#1#3'top'#2'{'#0#9
+'TMenuItem'#9'MenuItem1'#7'Caption'#6#22'Remove from conversion'#7'OnClick'#7
+#14'MenuItem1Click'#0#0#0#0
]);

View File

@ -1,15 +1,9 @@
TLAZCONVERTERFORM.CAPTION=Codepage LazConverter for PAS, LFM, LRS & INC files v0.0.4
TLAZCONVERTERFORM.CAPTION=Codepage LazConverter for PAS, LFM, LRS, LRT & INC files v0.0.6
TLABEL.CAPTION=Path to your project:
TBUTTON.CAPTION=Path
TLABEL.CAPTION=Convert From:
TLABEL.CAPTION=Convert To:
TCHECKBOX.CAPTION=Include subdirectories
TLABEL.CAPTION=Ready...
TBUTTON.CAPTION=Path
TBUTTON.CAPTION=Search
TBUTTON.CAPTION=Convert
TLABEL.CAPTION=Directory:
TLABEL.CAPTION=Ready...
TBUTTON.CAPTION=Remove from conversion
TBUTTON.CAPTION=View
TMENUITEM.CAPTION=View File
TMENUITEM.CAPTION=-
TMENUITEM.CAPTION=Remove From Conversion
TMENUITEM.CAPTION=Remove from conversion

View File

@ -28,7 +28,7 @@ interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls, Buttons, ComCtrls, Menus
{$IFDEF TRANSLATESTRING}, DefaultTranslator{$ENDIF};
{$IFDEF TRANSLATESTRING}, DefaultTranslator{$ENDIF}, FileCtrl;
type
@ -38,32 +38,35 @@ type
Button1: TButton;
Button2: TButton;
Button3: TButton;
CheckBox1: TCheckBox;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
Edit1: TEdit;
FileListBox1: TFileListBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label6: TLabel;
Memo1: TMemo;
MenuItem1: TMenuItem;
Panel1: TPanel;
PopupMenu1: TPopupMenu;
ProgressBar1: TProgressBar;
SelectDirectoryDialog1: TSelectDirectoryDialog;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Form1Show(Sender: TObject);
procedure MenuItem1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
procedure CountFiles;
end;
var
LazConverterForm: TLazConverterForm;
allfiles:tstringlist;
const msgdone = 'Searching done... press CONVERT button! Files: ';
implementation
@ -83,218 +86,34 @@ begin
result:=tmp;
end;
Function LocWord(StartAT,Wordno:integer;Str:string):integer;
{local proc used by PosWord and Extract word}
var
W,L: integer;
Spacebefore: boolean;
procedure TLazConverterForm.CountFiles;
begin
If (Str = '') or (wordno < 1) or (StartAT > length(Str)) then
begin
LocWord := 0;
exit;
end;
SpaceBefore := true;
W := 0;
L := length(Str);
StartAT := pred(StartAT);
While (W < Wordno) and (StartAT <= length(Str)) do
begin
StartAT := succ(StartAT);
If SpaceBefore and (Str[StartAT] <> ' ') then
begin
W := succ(W);
SpaceBefore := false;
end
else
If (SpaceBefore = false) and (Str[StartAT] = ' ') then
SpaceBefore := true;
end;
If W = Wordno then
LocWord := StartAT
else
LocWord := 0;
end;
Function ExtractWords(StartWord,NoWords:integer;Str:string):string;
var Start, finish : integer;
begin
If Str = '' then
begin
ExtractWords := '';
exit;
end;
Start := LocWord(1,StartWord,Str);
If Start <> 0 then
finish := LocWord(Start,succ(NoWords),Str)
else
begin
ExtractWords := '';
exit;
end;
If finish = 0 then {5.02A}
finish := succ(length(Str));
Repeat
finish := pred(finish);
Until Str[finish] <> ' ';
ExtractWords := copy(Str,Start,succ(finish-Start));
end; {Func ExtractWords}
Function WordCnt(Str:string):integer;
var
W,I: integer;
SpaceBefore: boolean;
begin
If Str = '' then
begin
WordCnt := 0;
exit;
end;
SpaceBefore := true;
W := 0;
For I := 1 to length(Str) do
begin
If SpaceBefore and (Str[I] <> ' ') then
begin
W := succ(W);
SpaceBefore := false;
end
else
If (SpaceBefore = false) and (Str[I] = ' ') then
SpaceBefore := true;
end;
WordCnt := W;
end;
function IsIn(Iskano:string; baza:string):boolean;
var
index,mindex,counter:integer;
tmp1:string;
tmp2:string;
begin
result:=false;
tmp1:=uppercase(iskano);
tmp2:=uppercase(baza);
counter:=0;
if pos('"',tmp1)<>0 then
if FileListBox1.Items.Count-1<>-1 then
begin
mindex:=1;
tmp1:=Replace(tmp1,'"','');
if pos(tmp1,tmp2)<>0 then
begin
counter:=1;
end;
end else
begin
mindex:=WordCnt(tmp1);
if mindex>0 then
begin
for index:=1 to mindex do
begin
if Pos(ExtractWords(index,1,tmp1),tmp2)<>0 then inc(counter);
end;
end;
end;
if counter=mindex then
begin
result:=true;
end;
label6.caption:=msgdone+inttostr(FileListBox1.Items.Count-1);
end else label6.caption:=msgdone+'0';
end;
procedure GetAllFiles(mask: string; unignore:string; subdirs:boolean);
var
search: TSearchRec;
directory: string;
tmp:string;
const
{$ifdef unix}
msk='*';
delimeter='/';
{$else}
msk='*.*';
delimeter='\';
{$endif}
begin
directory := ExtractFilePath(mask);
// find all files
if FindFirst(mask, faAnyFile-faDirectory, search) = 0 then
begin
repeat
// add the files to the listbox
tmp:=trim(ExtractFileExt(search.Name));
if tmp<>'' then
begin
if pos('.',tmp)=1 then delete(tmp,1,1);
if IsIn(tmp,unignore) then
begin
allfiles.add(directory + search.Name);
end;
end;
until FindNext(search) <> 0;
end;
if subdirs then
begin
// Subdirectories/ Unterverzeichnisse
if FindFirst(directory + msk, faDirectory, search) = 0 then
begin
repeat
if ((search.Attr and faDirectory) = faDirectory)
and (search.Name[1] <> '.') and (search.Name<>'') then
GetAllFiles(directory + search.Name + delimeter + ExtractFileName(mask),
unignore,subdirs);
until FindNext(search) <> 0;
FindClose(search);
end;
end;
end;
{ TLazConverterForm }
procedure TLazConverterForm.Button1Click(Sender: TObject);
begin
if SelectDirectoryDialog1.Execute then
begin
edit1.text:=IncludeTrailingPathDelimiter(ExtractFileDir(SelectDirectoryDialog1.FileName));
edit1.text:=IncludeTrailingPathDelimiter(SelectDirectoryDialog1.FileName);
end;
end;
procedure TLazConverterForm.Button2Click(Sender: TObject);
var tmp:string;
const
{$ifdef unix}
msk='*';
{$else}
msk='*.*';
{$endif}
begin
memo1.text:='';
tmp:=trim(Edit1.text);
if tmp='' then
if trim(edit1.text)='' then
begin
button1click(sender);abort;
end;
edit1.text:=IncludeTrailingPathDelimiter(tmp);
if DirectoryExists(tmp) then
begin
AllFiles.Text:='';
GetAllFiles(tmp+msk,'pas lfm lrs inc',checkbox1.checked);
label6.caption:='Searching done... press CONVERT button! Files: '+inttostr(allfiles.count);
memo1.text:=allfiles.text;
caption:=allfiles[0];
end;
FileListBox1.Mask:='';
FileListBox1.Directory:='';
FileListBox1.Clear;
FileListBox1.Directory:=Edit1.text;
FileListBox1.Mask:='*.pas;*.lfm;*.lrs;*.inc;*.lrt';
CountFiles;
end;
procedure TLazConverterForm.Button3Click(Sender: TObject);
@ -390,31 +209,31 @@ var tmp:tstringlist;
end;
begin
if allfiles.Count-1=-1 then abort;
if FileListBox1.Items.count-1=-1 then abort;
if trim(combobox1.text)='' then abort;
if trim(combobox2.text)='' then abort;
tmp:=tstringlist.create;
try
ProgressBar1.Min:=0;
ProgressBar1.Max:=allfiles.count;
ProgressBar1.Max:=FileListBox1.Items.count;
ProgressBar1.StepBy(1);
for i:=0 to allfiles.count-1 do
for i:=0 to FileListBox1.Items.count-1 do
begin
ok:=true;
try
tmp.LoadFromFile(allfiles[i]);
tmp.LoadFromFile(FileListBox1.Directory+FileListBox1.Items[i]);
except
ok:=false;
end;
if ok then
begin
if pos('.LRS',uppercase(allfiles[i]))<>0 then
if uppercase(ExtractFileExt(FileListBox1.Items[i]))='.LRS' then
begin
if ConvertMeLRS(tmp) then
begin
ok:=true;
try
tmp.SaveToFile(allfiles[i]);
tmp.SaveToFile(FileListBox1.Directory+FileListBox1.Items[i]);
except ok:=false; end;
end;
end else
@ -423,7 +242,7 @@ begin
begin
ok:=true;
try
tmp.SaveToFile(allfiles[i]);
tmp.SaveToFile(FileListBox1.Directory+FileListBox1.Items[i]);
except ok:=false; end;
end;
end;
@ -434,6 +253,9 @@ begin
ProgressBar1.Position:=0;
tmp.free;
label6.caption:='Done!';
FileListBox1.Mask:='';
FileListBox1.Directory:='';
FileListBox1.Clear;
end;
end;
@ -448,15 +270,25 @@ begin
except end;
ComboBox1.text:='';
ComboBox2.text:='';
CheckBox1.Checked:=True;
Edit1.SetFocus;
FileListBox1.Mask:='';
FileListBox1.Directory:='';
FileListBox1.Clear;
end;
procedure TLazConverterForm.MenuItem1Click(Sender: TObject);
begin
if FileListBox1.Items.count-1=-1 then abort;
try
FileListBox1.Items.Delete(FileListBox1.ItemIndex);
except end;
CountFiles;
end;
initialization
{$I mainunit.lrs}
allfiles:=tstringlist.create;
finalization
allfiles.free;
end.

View File

@ -7,4 +7,4 @@
198
230
208
240
240