Contents | Prev | Next

7.2.64 The system function

Description

The system function passes a command to the command processor for execution, and returns the resulting error code. If there is an error executing the command then a non-zero value indicating the kind of error is returned. If there is no error executing the command then the value returned is zero. The type of the value returned by this function is always integer.

Parameter

The system function's only parameter is an expression of string type or char type, and is the command to send to the command processor.

Example

For example the simple program batch.pas below is a very primitive batch processor. It sends each line in the input file to the command processor to be executed.

   program batch(f, output);
   var
      f : text;
      s : string;
      err : integer;
   begin
      reset(f);    (* open input file or standard input file *)
      while not eof(f) do
      begin
        readln(f, s);
        writeln('Executing ', s);
        err := system(s);      (* Pass 's' to the command processor *)
        writeln('Error code is ', err)
     end
   end.

Portability

Operating Systems: All
Standard Pascal: No

Contents | Prev | Next