The system function


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.


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.


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);
      f : text;
      s : string;
      err : integer;
      reset(f);    (* open input file or standard input file *)
      while not eof(f) do
        readln(f, s);
        writeln('Executing ', s);
        err := system(s);      (* Pass 's' to the command processor *)
        writeln('Error code is ', err)


Operating Systems: All
Standard Pascal: No