[fpc-pascal] including libraies ?

2010-03-14 Thread Terry A. Haimann

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.


Thanks in advance,   TH
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] including libraies ?

2010-03-14 Thread Paul Nicholls
- Original Message - 
From: Terry A. Haimann te...@haimannonline.com

To: fpc-pascal@lists.freepascal.org
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 


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal