faqts : Computers : Programming : Languages : Tse : Language : Computer : Delphi

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

12 of 16 people (75%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

TSE: Language: Computer: Compile: Delphi: How to run Delphi command line from TSE?

Oct 4th, 2003 14:06
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 19 Februari 2002 - 09:16 pm -------------------

TSE: Language: Computer: Compile: Delphi: How to run Delphi command 
line from TSE?

Steps: Overview:

1. make sure you have Delphi installed, so that e.g. dcc32.exe can be 
found on
your computer

2.1 Create a batchfile 'comdelph.bat', containing this text
(adapt it to your system) and store this batchfile in your TSE 
directory
(e.g. save to c:\mytsedirectory\comdelph.bat)

   @c:\progra~1\borland\delphi7\bin\dcc32.exe -Ic:\progra~1
\borland\delphi7\lib -Rc:\progra~1\borland\delphi7\lib %1

   @IF errorlevel=1 GOTO fail
   %1.exe
   @GOTO end

   :fail
   @ECHO.
   @ECHO.
   @ECHO.
   @ECHO There where errors found while compiling your program.
   @ECHO.
   @ECHO Could not compile to .exe...
   @ECHO.
   @ECHO.

   :end
   @PAUSE
   @EXIT

2.2 The 'comdelph.bat' batch file I use myself is a bit changed:

    copy %3 c:\temp\%1.pas
    c:\progra~1\borland\delphi7\bin\dcc32.exe -Ic:\progra~1
\borland\delphi7\lib -Rc:\progra~1\borland\delphi7\lib -cc -q -v -h -w 
c:\temp\%1.pas

    @IF errorlevel=1 GOTO fail
    c:\temp\%1
    @GOTO end

    :fail
    @ECHO.
    @ECHO.
    @ECHO.
    @ECHO There where errors found while compiling your program.
    @ECHO.
    @ECHO Could not compile to .exe...
    @ECHO.
    @ECHO.

    :end
    @PAUSE
    @EXIT

3. Adapt the compiler information

   1. in TSE, after loading any file (but preferably a .pas file),
      press <SHIFT><F9>

   2. then 'D' for debug compiler setup

   3. then <ALT><C> to copy one of the compiler settings present

   4. then change the fields:

   'Extension' to: .pas
   'Description' to: Borland Delphi command line dcc32.exe
   'Command' to: c:\mytsedirectory\comdelph.bat &name& &ext& &fn& > 
&output&

     Note: In e.g. TSE v4.x, you have by default already an entry in
           your list of compilers 'Borland Delphi (console)', which has
           the following defined:

            dcc32 -cc -q -v -h -w &fn& > &output&

           This also works fine, but does not run the
           resulting .exe file also.

   5. make sure this information is permanently stored in the compiler
      information (via <ENTER>, then <ESCAPE>)

4. If you now load a Delphi file, fill in some program code for Delphi,
   for example type or copy this text in a file 'mytest.pas':

--- cut here ---------------------------------------------------------

    program Greeting;

    {$APPTYPE CONSOLE}

    begin
     WriteLn( 'Hello world from Delphi' );
    end.

--- cut here ---------------------------------------------------------

   1. save that text in your TSE directory (but my batch
      file should do that for you automatically, here
      by saving it in the c:\temp directory)

   2. then press <CTRL><F9> or <ESCAPE><M><C> to compile,

   3. this will run that batch file,

   4. which runs dcc32.exe with your filename as a command line
      parameter

   5. then runs your compiled .exe file

5. A typical output screen would then be:

+--------------------------------------------------------------------+
|> copy c:\BBC\TAAL\dddpas1.pas c:\temp\dddpas1.pas                  |
|  1 file(s) copied.                                                 |
|                                                                    |
|> c:\progra~1\borland\delphi7\bin\dcc32.exe                         |
|  -Ic:\progra~1\borland\delphi7\lib                                 |
|  -Rc:\progra~1\borland\delphi7\lib                                 |
|  -cc -q -v -h -w c:\temp\dddpas1.pas                               |
|                                                                    |
|Borland Delphi Version 15.0                                         |
|Copyright (c) 1983,2002 Borland Software Corporation                |
|9 lines, 0.05 seconds, 10456 bytes code, 1801 bytes data.           |
|                                                                    |
|> c:\temp\dddpas1                                                   |
|                                                                    |
|Hello world from Delphi                                             |
|                                                                    |
|Press any key to continue . . .                                     |
+--------------------------------------------------------------------+

---

Tested and working OK in TSE v4.x [kn, ni, sa, 13-09-2003  0:45:31]

---

[Internet: see also: 

Computer: Wordprocessor: TSE: Language: Computer: Compile: Run: 
Overview
http://www.faqts.com/knowledge_base/view.phtml/aid/24311/fid/895

----------------------------------------------------------------------