Board index » delphi » Executing Files and Graphics

Executing Files and Graphics

Hello all,

I am writing a program that will be run off of a bootable cd, and so far,
i've come across 2 problems.  One is kinda major, the other is not:

1.  major problem - I'm trying to Use Exec to shell out to dos, but i don't
seem to be getting anything done.  this is what my code looks like:

readkey;
dos.Exec('bat\format.bat','');
SwapVectors;
clrscr;
gotoxy(12,12);
WriteLn('...back from Exec');
if DosError <> 0 then{ Error?}
 begin
  gotoxy(12,15);
  WriteLn('Dos error #', DosError);
 end
  else
  gotoxy(12,15);
    WriteLn('Exec successful. ',
      'Child process exit code = ',
    DosExitCode);

when i run it, i get back a dosexit code of 0.  not sure why it doesn't
work.

2.  the other problem is minor in comparison.  all i need to do is to
display an image(company logo).  since i couldn't figure it out on my own, i
went ahead and drew via graph and line, circle etc.  it looks okay, but if i
could use the original jpg(bmp, gif, whatever) that would be much better.

Thanks in advance

Bryant

 

Re:Executing Files and Graphics


In article <KMSj2.1470$wP4.2...@server1.news.adelphia.net> "Darkstorm" <darksto...@hotmail.com> writes:

Quote
>1.  major problem - I'm trying to Use Exec to shell out to dos, but i don't
>seem to be getting anything done.  this is what my code looks like:
>readkey;
>dos.Exec('bat\format.bat','');
>SwapVectors;
>clrscr;
>gotoxy(12,12);
>WriteLn('...back from Exec');
>if DosError <> 0 then{ Error?}
> begin
>  gotoxy(12,15);
>  WriteLn('Dos error #', DosError);
> end
>  else
>  gotoxy(12,15);
>    WriteLn('Exec successful. ',
>      'Child process exit code = ',
>    DosExitCode);
>when i run it, i get back a dosexit code of 0.  not sure why it doesn't
>work.

I think you should use the compiler directive {$M} to gain memory for your
program (format.bat) that you run with EXEC.

Try to put the following on the beginning of your program:

{$M $800,0,0}
                                        SOFT

Re:Executing Files and Graphics


Quote
Darkstorm wrote:
> 1.  major problem - I'm trying to Use Exec to shell out to dos, but i don't
> seem to be getting anything done.  this is what my code looks like:

> readkey;
> dos.Exec('bat\format.bat','');
> SwapVectors;
> clrscr;
> gotoxy(12,12);
> WriteLn('...back from Exec');
> if DosError <> 0 then{ Error?}
>  begin
>   gotoxy(12,15);
>   WriteLn('Dos error #', DosError);
>  end
>   else
>   gotoxy(12,15);
>     WriteLn('Exec successful. ',
>       'Child process exit code = ',
>     DosExitCode);

> when i run it, i get back a dosexit code of 0.  not sure why it doesn't
> work.

COMMAND.COM always returns zero.

Re:Executing Files and Graphics


On Sun, 3 Jan 1999 18:12:57 -0500, "Darkstorm"

Quote
<darksto...@hotmail.com> wrote:
>Hello all,

>I am writing a program that will be run off of a bootable cd, and so far,
>i've come across 2 problems.  One is kinda major, the other is not:

>1.  major problem - I'm trying to Use Exec to shell out to dos, but i don't
>seem to be getting anything done.  this is what my code looks like:

>readkey;

Add "Swapvectors;" here. You must swap the vectors before and after
the exec.

Quote
>dos.Exec('bat\format.bat','');

Why is here "dos.exec" instead of just "exec"?

Quote
>SwapVectors;
>clrscr;
>gotoxy(12,12);
>WriteLn('...back from Exec');
>if DosError <> 0 then{ Error?}
> begin
>  gotoxy(12,15);
>  WriteLn('Dos error #', DosError);
> end
>  else
>  gotoxy(12,15);
>    WriteLn('Exec successful. ',
>      'Child process exit code = ',
>    DosExitCode);

>when i run it, i get back a dosexit code of 0.  not sure why it doesn't
>work.

There must be enough space in memory to run other programs with EXEC.
Pascal reserves all available space in convenctional memory for your
program's heap. Try adding {$M $4000,0,0} in the beginning.

Quote

>2.  the other problem is minor in comparison.  all i need to do is to
>display an image(company logo).  since i couldn't figure it out on my own, i
>went ahead and drew via graph and line, circle etc.  it looks okay, but if i
>could use the original jpg(bmp, gif, whatever) that would be much better.

At "x2ftp.oulu.fi" you can find descriptions for all sorts of file
formats. I have a program with source in pascal that writes PCX files
on my page (it's well commented). URL is

http://www.geocities.com/siliconvalley/lab/2503

I hope that solves your problems.

Conrad.

Re:Executing Files and Graphics


Quote
Darkstorm wrote:
> 1.  major problem - I'm trying to Use Exec to shell out to dos, but i don't
> seem to be getting anything done.  this is what my code looks like:

> readkey;
> dos.Exec('bat\format.bat','');

You're happy that this did not crash the computer. You can only use exec to run
.EXE oder .COM programs, it does not interprete .BATs. Use

        exec (GetEnv(ComSpec), '/c bat\format.bat');

instead and COMMAND.COM will do the interpretation.

        Bye,
          Ingo

Re:Executing Files and Graphics


Quote
Darkstorm wrote:
> 1.  major problem - I'm trying to Use Exec to shell out to dos, but i don't
> seem to be getting anything done.  this is what my code looks like:

> dos.Exec('bat\format.bat','');
> ...

You can't "exec" a BAT file.  You can only "exec" a COM or EXE file.
If you want to run a BAT file, you need to exec a call to COMMAND.COM
and then pass it the BAT file as a command-line parameter:

  dos.Exec(getenv('comspec');'/c bat\format.bat');

This might help...

     - Rich

Other Threads