Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-03

including libraies ?

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Terry A. Haimann

I tried to write a little utility to submit a command to code to do this is as follows:

program TestPrg;
Uses Classes, Process;
Var
    i:    Integer;
    Cmd, Pre, Post, StrVar, SwStr:    String;
    MyProcess: TProcess;
    SOut, EOut, StdStrLst: TStringList;
Begin
    StdStrLst   := TStringlist.Create;
    SOut   := TStringlist.Create;
    EOut   := TStringlist.Create;
      EOut := TStringlist.Create;
      MyProcess := TProcess.Create(nil);
      MyProcess.CommandLine := 'at now';
      MyProcess.Options := MyProcess.Options + [poUsePipes];
      MyProcess.Execute;
      StdStrLst.Clear;
      StdStrLst.Add('awk -F":" ''{print $1"\t"$3"\t"$4}'' /etc/passwd |
sort');
      StdStrLst.SaveToStream(MyProcess.Input);
      StdStrLst.Clear;
      StdStrLst.Add(chr(4));
      StdStrLst.SaveToStream(MyProcess.Input);
      SOut.LoadFromStream(MyProcess.Output);
      For i:=1 to SOut.Count Do
          WriteLn(SOut.Strings[i]);
      EOut.LoadFromStream(MyProcess.StdErr);
      For i:=1 to EOut.Count Do
          WriteLn(EOut.Strings[i]);
End.

Running this code from a Lazarus test program works with out any problems. When running it from a Free Pascal (non gui,) the program finishes normally, but nothing gets submitted to Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Process;

Someone on the Lazarus List recommend I add SysUtils to my utility program. I am not sure how to do this. SysUtils has many included files in there and they are all in other directories, none of which are in my path. I am sure there is some simple method here that I am totally ignorant of.

Thanks in advance, TH

Paul Nicholls
to Terry A. Haimann

----- Original Message -----

Earlier message 66 lines
From: "Terry A. Haimann" To: Sent: Monday, March 15, 2010 9:11 AM Subject: [fpc-pascal] including libraies ? >I tried to write a little utility to submit a command to the At Facility. > > The code to do this is as follows: > > program TestPrg; > > Uses Classes, Process; > > Var > i: Integer; > Cmd, Pre, Post, StrVar, SwStr: String; > MyProcess: TProcess; > SOut, EOut, StdStrLst: TStringList; > > Begin > StdStrLst := TStringlist.Create; > SOut := TStringlist.Create; > EOut := TStringlist.Create; EOut := TStringlist.Create; MyProcess := > TProcess.Create(nil); MyProcess.CommandLine := 'at now'; > MyProcess.Options := MyProcess.Options + [poUsePipes]; MyProcess.Execute; > StdStrLst.Clear; > StdStrLst.Add('awk -F":" ''{print $1"\t"$3"\t"$4}'' /etc/passwd | > sort'); StdStrLst.SaveToStream(MyProcess.Input); StdStrLst.Clear; > StdStrLst.Add(chr(4)); > StdStrLst.SaveToStream(MyProcess.Input); > SOut.LoadFromStream(MyProcess.Output); > For i:=1 to SOut.Count Do > WriteLn(SOut.Strings[i]); > EOut.LoadFromStream(MyProcess.StdErr); > For i:=1 to EOut.Count Do > WriteLn(EOut.Strings[i]); > End. > > > Running this code from a Lazarus test program works with out any problems. > When running it from a Free Pascal (non gui,) the program finishes > normally, but nothing gets submitted to the AT Facility. > uses Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, > Dialogs, > StdCtrls, Process; > > Someone on the Lazarus List recommend I add SysUtils to my utility > program. I am not sure how to do this. SysUtils has many included files > in there and they are all in other directories, none of which are in my > path. I am sure there is some simple method here that I am totally > ignorant of. > HI Terry, you should be able to just include SysUtils in your uses clause without any issues. The compiler should be able to find that unit (and others needed) automatically... {code} Uses Classes, Process,SysUtils; {code} cheers, Paul