?
Solved

Export Project Source Code

Posted on 2005-04-12
8
Medium Priority
?
179 Views
Last Modified: 2010-04-05
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?
0
Comment
Question by:mcmahling
  • 4
  • 2
  • 2
8 Comments
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 13768060
from delphi 5 onwards, the form text is saved in a text readable format by default. (.dfm)

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.
0
 
LVL 17

Expert Comment

by:mokule
ID: 13768170
I think mcmahling mean something different
i would advice
copy *.pas dest.txt
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 13768179
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
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 17

Expert Comment

by:mokule
ID: 13768201
If You want convert dfm files from binery to text before merging use delphi program convert.exe
0
 
LVL 17

Accepted Solution

by:
TheRealLoki earned 2000 total points
ID: 13768215
ALT-Tools-Environment Options

"New Forms as Text"      Toggles the format in which form files are saved. The form files in your project can be saved in one of two formats: binary or text. Text files can be modified more easily by other tools and managed by a version control system. Binary files are backward compatible with earlier versions of Delphi. (You can override this setting on individual forms by right-clicking and checking or unchecking the Text DFM command.)

now, in dos,
cd c:\mysourcedirectory
copy *.dfm All_DFM.txt
copy *.pas All_PAS.txt
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 13768259
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.Items[I]);
  memMain.Lines.Add(ExtractFileName(lbxFiles.Items[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(dlgSave.FileName);
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
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 13768270
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
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 13768302
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.Items[I]);
  memMain.Lines.Add(ExtractFileName(lbxFiles.Items[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


0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question