Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4106
Number of posts: 14016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Dos Commands Posted by sad.boy on 26 Nov 2005 at 9:32 AM
how can i tell in pascal to execute some dos commands in a specified line of my program,i know the dos unit and some commands like exec command but how can i perform say format or xcopy or commands like this?

No One Knows What Is Like To Be The Sad Boy
Report
Re: Dos Commands Posted by Alcatiz on 26 Nov 2005 at 2:09 PM
: how can i tell in pascal to execute some dos commands in a specified line of my program,i know the dos unit and some commands like exec command but how can i perform say format or xcopy or commands like this?
:
: No One Knows What Is Like To Be The Sad Boy
:
Hi !

You can execute the command interpreter this way :

SwapVectors;
Exec(GetEnv('COMSPEC'),'/C xcopy...');

Report
Re: Dos Commands Posted by Phat Nat on 26 Nov 2005 at 9:11 PM
: : how can i tell in pascal to execute some dos commands in a specified line of my program,i know the dos unit and some commands like exec command but how can i perform say format or xcopy or commands like this?
: :
: : No One Knows What Is Like To Be The Sad Boy
: :
: Hi !
:
: You can execute the command interpreter this way :

To add to your code, you can have a procedure like this:

FUNCTION DosCmd(Cmd : String) : Boolean;
Begin
     SwapVectors;
     Exec(GetEnv('COMSPEC'),'/C '+Cmd);
     SwapVectors;
     DosCmd := Boolean(DosError);
End;



Then you can just pass the DOS commands to the function and it will return TRUE if it worked.

Phat Nat

Report
Re: Dos Commands Posted by sad.boy on 28 Nov 2005 at 7:15 AM
Thanks You all guys ,i'll try that and i let u know if i had any problems!


:x To You All ;)
Report
Re: Dos Commands Posted by zibadian on 26 Nov 2005 at 2:12 PM
: how can i tell in pascal to execute some dos commands in a specified line of my program,i know the dos unit and some commands like exec command but how can i perform say format or xcopy or commands like this?
:
: No One Knows What Is Like To Be The Sad Boy
:
Here is an example code to format a floppy disk:
  
{$M 20480, 0, 65520} 

uses
  Dos;

begin
  SwapVectors;
  Exec('format a:','');
  SwapVectors;
end.

The statements used are explained in the help files.
Report
Re: Dos Commands Posted by sad.boy on 28 Nov 2005 at 6:53 PM
I tried things you told me,the code gets compiled but it passes the command line as if it is a comment :(
what should i do?
FUNCTION DosCmd(Cmd : String) : Boolean;
Begin
     SwapVectors;
     Exec(GetEnv('COMSPEC'),'/C '+Cmd);
     SwapVectors;
     DosCmd := Boolean(DosError);
End;

what is wring with this function? i exactly typed above ,i just replaced
format a: instead of cmd and the other things are just above function
what is wring with it?(by the way what is that copspec in single''?

Report
Re: Dos Commands Posted by zibadian on 28 Nov 2005 at 10:42 PM
: I tried things you told me,the code gets compiled but it passes the command line as if it is a comment :(
: what should i do?
:
: FUNCTION DosCmd(Cmd : String) : Boolean;
: Begin
:      SwapVectors;
:      Exec(GetEnv('COMSPEC'),'/C '+Cmd);
:      SwapVectors;
:      DosCmd := Boolean(DosError);
: End;
: 

: what is wring with this function? i exactly typed above ,i just replaced
: format a: instead of cmd and the other things are just above function
: what is wring with it?(by the way what is that copspec in single''?
:
:
Did you also reduce the heap size?
COMSPEC is the name of an enviromental variable, which points to the command interpreter.
Report
Re: Dos Commands Posted by sad.boy on 29 Nov 2005 at 3:37 AM
Yeah Thats iT the heap memory!
it works fine now!
but some thing is not clear to memory we expand the heap memory to pass
the code segmen memory that is just 64kb ,isn't it?
so we have to expand it not reduce it! please tell me if i'm wrong
( I Guess :D ;) )

Report
Re: Dos Commands Posted by zibadian on 29 Nov 2005 at 4:04 AM
: Yeah Thats iT the heap memory!
: it works fine now!
: but some thing is not clear to memory we expand the heap memory to pass
: the code segmen memory that is just 64kb ,isn't it?
: so we have to expand it not reduce it! please tell me if i'm wrong
: ( I Guess :D ;) )
:
:
You're wrong.
By default each Pascal program reserves all the conventional memory for itself. Most of this memory consists of the heap. If you want to run a child process, you'll need to free some of that memory for the child process, because the child doesn't run inside the heap of your program. This means that you need to reduce the memory reservation of your program, hence you'll need to reduce the heap size.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.