Board index » delphi » 3 easy problem i think, Help Help

3 easy problem i think, Help Help

Hi

I hope you can help me.

1.How can i execute a dos program from my Delphi app.

2.How can i make a check for a fil, if is there.

3.My program make a ini file, but default is windows dir.
  How can i make it too save in the app dir (but not by default).
  I mean if it is on anothere pc, then it can by my dir.

Please type it clear, im not new, but im not good at this.

S{*word*249} B.

 

Re:3 easy problem i think, Help Help


In article <31E925F0.4...@mbox300.swipnet.se>,
S{*word*249} B?rlum  <s{*word*249}.bor...@mbox300.swipnet.se> wrote:

Quote
>2.How can i make a check for a fil, if is there.

Use FileExists(Filename).

Quote
>3.My program make a ini file, but default is windows dir.
>  How can i make it too save in the app dir (but not by default).

Try this:
MyINI := TINIFile.Create(ExtractFilePath(Application.ExeName) + 'MyApp.ini');

ExtractFilePath(Application.ExeName) will give you the directory that your
program was run from.

Good luck,

  David

--
David Weisberger
djwei...@insti.physics.sunysb.edu

Re:3 easy problem i think, Help Help


In Article<31E925F0.4...@mbox300.swipnet.se>, <s{*word*249}.bor...@mbox300.swipnet.se> write:

Quote
> Path: iafrica.com!pipex-sa.net!plug.news.pipex.net!pipex!tank.news.pipex.net!pipex!news.mathworks.com!zombie.ncsc.mil!nntp.coast.net!news00.sunet.se!sunic!mn6.swip.net!mn5.swip.net!news
> From: S{*word*249} B?rlum <s{*word*249}.bor...@mbox300.swipnet.se>
> Newsgroups: comp.lang.pascal.delphi.databases
> Subject: 3 easy problem i think, Help Help
> Date: Sun, 14 Jul 1996 18:53:04 +0200
> Organization: Privat
> Lines: 15
> Message-ID: <31E925F0.4...@mbox300.swipnet.se>
> NNTP-Posting-Host: dialup106-1-2.swipnet.se
> Mime-Version: 1.0
> Content-Type: text/plain; charset=iso-8859-1
> Content-Transfer-Encoding: 8bit
> NNTP-Posting-User: 033aeff23ec8c2ee257f2d2216560894
> X-Mailer: Mozilla 2.0 (Win95; I)

> Hi

> I hope you can help me.

> 1.How can i execute a dos program from my Delphi app.

> 2.How can i make a check for a fil, if is there.

> 3.My program make a ini file, but default is windows dir.
>   How can i make it too save in the app dir (but not by default).
>   I mean if it is on anothere pc, then it can by my dir.

> Please type it clear, im not new, but im not good at this.

> S{*word*249} B.

To execute a dos program I created a PIF file useing windows PIF editor.  I
then used the delphi windows command WINEXEC ('\dir\dir2\exec.exe', SW_????) ;

To check for files use the FILEEXISTS ('\dir\dir2\file.txt') ; command.  It
returns True or False ;

Re:3 easy problem i think, Help Help


Quote
S{*word*249} B?rlum <s{*word*249}.bor...@mbox300.swipnet.se> wrote:
>2.How can i make a check for a fil, if is there.

From the Delphi v2.0 Help file:

Declaration

function FileExists(const FileName: string): Boolean;

Description

The FileExists function returns True if the file specified by FileName
exists. If the file does not exist, FileExists returns False.

Quote
>3.My program make a ini file, but default is windows dir.
>  How can i make it too save in the app dir (but not by default).
>  I mean if it is on anothere pc, then it can by my dir.

For an executable, 'Application.EXEName' contains the full path and
file name of the executable. What I do is use a small function that I
maintain in my set of "stock" units called GetDirectory. I pass the
EXEName property to the function, which simply steps backward through
the string until it hits a backslash, then returns
'COPY(InputString,1,BackslashPosition). You can use that return value
as the location for the program-specific .INI file (e.g.,
"INIFile.Create(ProgramDirectory+'XXX.INI')", where ProgramDirectory
is the return value from the GetDirectory function).

I hope this has been both helpful and clear (but I'd prefer helpful!)

H.B. Taylor

Re:3 easy problem i think, Help Help


Quote
> qost...@smartnet.net wrote in article

<4sf31i$...@doc.ponyexpress.net>...

Quote
> S{*word*249} B?rlum <s{*word*249}.bor...@mbox300.swipnet.se> wrote:
[snip]
> For an executable, 'Application.EXEName' contains the full path and
> file name of the executable. What I do is use a small function that I
> maintain in my set of "stock" units called GetDirectory. I pass the
> EXEName property to the function, which simply steps backward through
> the string until it hits a backslash, then returns
> 'COPY(InputString,1,BackslashPosition). You can use that return value
> as the location for the program-specific .INI file (e.g.,
> "INIFile.Create(ProgramDirectory+'XXX.INI')", where ProgramDirectory
> is the return value from the GetDirectory function).

Psst!  Here's a little secret, ExtractFilePath(Application.EXEName) will
do all that for you.  No fuss, no muss...

--
David S. Becker
ADP Dealer Services (Plaza R&D)
mailto:d...@plaza.ds.adp.com
(503)402-3236

Re:3 easy problem i think, Help Help


Quote
S{*word*249} B?rlum <s{*word*249}.bor...@mbox300.swipnet.se> wrote:
>Hi
>2.How can i make a check for a fil, if is there.

Look up the "FileExists()" function in the helpfiles.

Regards,

Tomas
-----------------------------------------------------
 Tomas Matuschek
 University of Vaxjo, Sweden
-----------------------------------------------------

Other Threads