mcmahling
asked on
Export Project Source Code
I have written a delphi program and I want to have all the source for all the forms in single text document. I know I can use something like editpro to open each form and save it as a text but that would take hours. Is there some program that can take the code from all the forms at once and export it to a text file?
I think mcmahling mean something different
i would advice
copy *.pas dest.txt
i would advice
copy *.pas dest.txt
Do you want the text from the *.dfm files as well as the text from the *.pas files, or just the *.pas files text?
sholmes
sholmes
If You want convert dfm files from binery to text before merging use delphi program convert.exe
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here is an example delphi project which you can run it in the project folder and it will load all *.pas, & *.dfm files into one document and allow you to save it to a file (text)
Hope this helps!
sholmes -
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, FileCtrl;
type
TForm1 = class(TForm)
btnLoad: TButton;
memMain: TMemo;
btnSave: TButton;
lbxFiles: TFileListBox;
dlgSave: TSaveDialog;
procedure btnLoadClick(Sender: TObject);
procedure btnSaveClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btnLoadClick(Sender : TObject);
var
I, J: Integer;
SL: TStringList;
begin
SL:= TStringList.Create;
for I:= 0 to lbxFiles.Count - 1 do
begin
SL.LoadFromFile(lbxFiles.I tems[I]);
memMain.Lines.Add(ExtractF ileName(lb xFiles.Ite ms[I]));
memMain.Lines.Add('');
memMain.Lines.Add('------- ---------- ---------- ---');
memMain.Lines.Add('');
for J:= 0 to SL.Count - 1 do
memMain.Lines.Add(SL[J]);
SL.Clear;
end;
SL.Free;
end;
procedure TForm1.btnSaveClick(Sender : TObject);
begin
if dlgSave.Execute then
memMain.Lines.SaveToFile(d lgSave.Fil eName);
end;
end.
object Form1: TForm1
Left = 201
Top = 145
Width = 870
Height = 640
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object btnLoad: TButton
Left = 40
Top = 104
Width = 75
Height = 25
Caption = 'Load'
TabOrder = 0
OnClick = btnLoadClick
end
object memMain: TMemo
Left = 144
Top = 96
Width = 689
Height = 473
TabOrder = 1
end
object btnSave: TButton
Left = 40
Top = 136
Width = 75
Height = 25
Caption = 'Save'
TabOrder = 2
OnClick = btnSaveClick
end
object lbxFiles: TFileListBox
Left = 48
Top = 224
Width = 57
Height = 97
ItemHeight = 13
Mask = '*.pas;*.dfm'
TabOrder = 3
Visible = False
end
object dlgSave: TSaveDialog
DefaultExt = 'txt'
Filter = 'Text File (*.txt)|*.txt'
Left = 72
Top = 192
end
end
Hope this helps!
sholmes -
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, FileCtrl;
type
TForm1 = class(TForm)
btnLoad: TButton;
memMain: TMemo;
btnSave: TButton;
lbxFiles: TFileListBox;
dlgSave: TSaveDialog;
procedure btnLoadClick(Sender: TObject);
procedure btnSaveClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btnLoadClick(Sender
var
I, J: Integer;
SL: TStringList;
begin
SL:= TStringList.Create;
for I:= 0 to lbxFiles.Count - 1 do
begin
SL.LoadFromFile(lbxFiles.I
memMain.Lines.Add(ExtractF
memMain.Lines.Add('');
memMain.Lines.Add('-------
memMain.Lines.Add('');
for J:= 0 to SL.Count - 1 do
memMain.Lines.Add(SL[J]);
SL.Clear;
end;
SL.Free;
end;
procedure TForm1.btnSaveClick(Sender
begin
if dlgSave.Execute then
memMain.Lines.SaveToFile(d
end;
end.
object Form1: TForm1
Left = 201
Top = 145
Width = 870
Height = 640
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object btnLoad: TButton
Left = 40
Top = 104
Width = 75
Height = 25
Caption = 'Load'
TabOrder = 0
OnClick = btnLoadClick
end
object memMain: TMemo
Left = 144
Top = 96
Width = 689
Height = 473
TabOrder = 1
end
object btnSave: TButton
Left = 40
Top = 136
Width = 75
Height = 25
Caption = 'Save'
TabOrder = 2
OnClick = btnSaveClick
end
object lbxFiles: TFileListBox
Left = 48
Top = 224
Width = 57
Height = 97
ItemHeight = 13
Mask = '*.pas;*.dfm'
TabOrder = 3
Visible = False
end
object dlgSave: TSaveDialog
DefaultExt = 'txt'
Filter = 'Text File (*.txt)|*.txt'
Left = 72
Top = 192
end
end
You will need the following components to build the application
2 TButtons
1 TMemo
1 TFileListBox
1 TSaveDialog
Set their properties to the property values shown in the DFM text i posted.
sholmes
2 TButtons
1 TMemo
1 TFileListBox
1 TSaveDialog
Set their properties to the property values shown in the DFM text i posted.
sholmes
This change in the routine adds a line at the end of every file
procedure TForm1.btnLoadClick(Sender : TObject);
var
I, J: Integer;
SL: TStringList;
begin
SL:= TStringList.Create;
for I:= 0 to lbxFiles.Count - 1 do
begin
SL.LoadFromFile(lbxFiles.I tems[I]);
memMain.Lines.Add(ExtractF ileName(lb xFiles.Ite ms[I]));
memMain.Lines.Add('');
memMain.Lines.Add('------- ---------- ---------- ---');
memMain.Lines.Add('');
for J:= 0 to SL.Count - 1 do
memMain.Lines.Add(SL[J]);
memMain.Lines.Add('');
memMain.Lines.Add('------- ---------- ---------- ---');
memMain.Lines.Add('');
SL.Clear;
end;
SL.Free;
end;
NOTE: if you do not want the *.dfm files, you can remove them from the mask of the TFileListbox
so you would have just - *.pas - vs- *.pas;*.dfm
sholmes
procedure TForm1.btnLoadClick(Sender
var
I, J: Integer;
SL: TStringList;
begin
SL:= TStringList.Create;
for I:= 0 to lbxFiles.Count - 1 do
begin
SL.LoadFromFile(lbxFiles.I
memMain.Lines.Add(ExtractF
memMain.Lines.Add('');
memMain.Lines.Add('-------
memMain.Lines.Add('');
for J:= 0 to SL.Count - 1 do
memMain.Lines.Add(SL[J]);
memMain.Lines.Add('');
memMain.Lines.Add('-------
memMain.Lines.Add('');
SL.Clear;
end;
SL.Free;
end;
NOTE: if you do not want the *.dfm files, you can remove them from the mask of the TFileListbox
so you would have just - *.pas - vs- *.pas;*.dfm
sholmes
If you would like to see the form text in design mode, simply click on the form, right click and choose "view form as text"
you can then right click and view it as normal.