📄 idlpr.pas
字号:
WriteStream(Data);
Write(#0);
CheckReply;
DoOnLPRStatus(psJobCompleted, JobID);
end; // if connected
except
on E: Exception do
DoOnLPRStatus(psError, E.Message);
end;
end;
function TIdLPR.GetQueueState(const AShortFormat: Boolean = false;
const AList : String = '') : String; {Do not Localize}
begin
DoOnLPRStatus(psGettingQueueState, AList);
if AShortFormat then
Write(#03 + Queue + ' ' + AList + LF) {Do not Localize}
else
Write(#04 + Queue + ' ' + AList + LF); {Do not Localize}
// This was the original code - problematic as this is more than one line
// read until I close the connection
// result:=ReadLn(LF);
Result := AllData;
DoOnLPRStatus(psGotQueueState, result);
end;
function TIdLPR.GetControlData: String;
var Data: String;
begin
try
Data:=''; {Do not Localize}
with ControlFile do
begin
// H - Host name
Data:=Data + 'H' + HostName + LF; {Do not Localize}
// P - User identification
Data:=Data + 'P' + UserName + LF; {Do not Localize}
// J - Job name for banner page
if Length(JobName) > 0 then
begin
Data:=Data + 'J' + JobName + LF; {Do not Localize}
end
else
begin
Data:=Data + 'JcfA' + JobId + HostName + LF; {Do not Localize}
end;
//mail when printed
if FMailWhenPrinted then
begin
Data:=Data + 'M' + UserName + LF; {Do not Localize}
end;
case FFileFormat of
ffCIF : // CalTech Intermediate Form
begin
Data:=Data + 'cdfA' + JobId + HostName + LF; {Do not Localize}
end;
ffDVI : // DVI (TeX output).
begin
Data:=Data + 'ddfA' + JobId + HostName + LF; {Do not Localize}
end;
ffFormattedText : //add formatting as needed to text file
begin
Data:=Data + 'fdfA' + JobId + HostName + LF; {Do not Localize}
end;
ffPlot : // Berkeley Unix plot library
begin
Data:=Data + 'gdfA' + JobId + HostName + LF; {Do not Localize}
end;
ffControlCharText : //text file with control charactors
begin
Data:=Data + 'ldfA' + JobId + HostName + LF; {Do not Localize}
end;
ffDitroff : // ditroff output
begin
Data:=Data + 'ndfA' + JobId + HostName + LF; {Do not Localize}
end;
ffPostScript : //Postscript output file
begin
Data:=Data + 'odfA' + JobId + HostName + LF; {Do not Localize}
end;
ffPR : //'pr' format {Do not Localize}
begin
Data:=Data + 'pdfA' + JobId + HostName + LF; {Do not Localize}
end;
ffFORTRAM : // FORTRAN carriage control
begin
Data:=Data + 'rdfA' + JobId + HostName + LF; {Do not Localize}
end;
ffTroff : //Troff output
begin
Data:=Data + 'ldfA' + JobId + HostName + LF; {Do not Localize}
end;
ffSunRaster : // Sun raster format file
begin
end;
end;
// U - Unlink data file
Data:=Data + 'UdfA' + JobId + HostName + LF; {Do not Localize}
// N - Name of source file
Data:=Data + 'NcfA' + JobId + HostName + LF; {Do not Localize}
if (FFileFormat = ffFormattedText) then
begin
if (IndentCount > 0) then
begin
Data:=Data + 'I' + IntToStr(IndentCount) + LF; {Do not Localize}
end;
if (OutputWidth > 0) then
begin
Data:=Data + 'W' + IntToStr(OutputWidth) + LF; {Do not Localize}
end;
end;
if Length(BannerClass) > 0 then
begin
Data:=Data + 'C' + BannerClass + LF; {Do not Localize}
end;
if BannerPage then
begin
Data:=Data + 'L' + UserName + LF; {Do not Localize}
end;
if Length(TroffRomanFont)>0 then
begin
Data:=Data + '1' + TroffRomanFont+LF; {Do not Localize}
end;
if Length(TroffItalicFont)>0 then
begin
Data:=Data + '2' + TroffItalicFont+LF; {Do not Localize}
end;
if Length(TroffBoldFont)>0 then
begin
Data:=Data + '3' + TroffBoldFont+LF; {Do not Localize}
end;
if Length(TroffSpecialFont)>0 then
begin
Data:=Data + '4' + TroffSpecialFont+LF; {Do not Localize}
end;
end;
Result:=data;
except
Result:='error'; {Do not Localize}
end;
end;
procedure TIdLPR.SeTIdLPRControlFile(const Value: TIdLPRControlFile);
begin
FControlFile.Assign(Value);
end;
destructor TIdLPR.Destroy;
begin
FreeAndNil(FControlFile);
inherited;
end;
procedure TIdLPR.PrintWaitingJobs;
begin
try
DoOnLPRStatus(psPrintingWaitingJobs, ''); {Do not Localize}
Write(#03 + Queue + LF);
CheckReply;
DoOnLPRStatus(psPrintedWaitingJobs, ''); {Do not Localize}
except
on E: Exception do
DoOnLPRStatus(psError, E.Message);
end;
end;
procedure TIdLPR.RemoveJobList(AList: String; const AAsRoot: Boolean =False);
begin
try
DoOnLPRStatus(psDeletingJobs, JobID);
if AAsRoot then
begin
{Only root can delete other people's print jobs} {Do not Localize}
Write(#05 + Queue + ' root ' + AList + LF); {Do not Localize}
end
else
begin
Write(#05 + Queue + ' ' + ControlFile.UserName + ' ' + AList + LF); {Do not Localize}
end;
CheckReply;
DoOnLPRStatus(psJobsDeleted, JobID);
except
on E: Exception do
DoOnLPRStatus(psError, E.Message);
end;
end;
procedure TIdLPR.CheckReply;
var ret : String;
begin
ret:=ReadString(1);
if (Length(ret) > 0) and (ret[1] <> #00) then
begin
raise EIdLPRErrorException.Create(Format(RSLPRError,[ret[1],JobID]));
end;
end;
procedure TIdLPR.DoOnLPRStatus(const AStatus: TIdLPRStatus;
const AStatusText: String);
begin
if Assigned(FOnLPRStatus) then
FOnLPRStatus(Self,AStatus,AStatusText);
end;
{ TIdLPRControlFile }
procedure TIdLPRControlFile.Assign(Source: TPersistent);
var cnt : TIdLPRControlFile;
begin
if Source is TIdLPRControlFile then
begin
cnt := Source as TIdLPRControlFile;
FBannerClass := cnt.BannerClass;
FIndentCount := cnt.IndentCount;
FJobName := cnt.JobName;
FBannerPage := cnt.BannerPage;
FUserName := cnt.UserName;
FOutputWidth := cnt.OutputWidth;
FFileFormat := cnt.FileFormat;
FTroffRomanFont := cnt.TroffRomanFont;
FTroffItalicFont := cnt.TroffItalicFont;
FTroffBoldFont := cnt.TroffBoldFont;
FTroffSpecialFont := cnt.TroffSpecialFont;
FMailWhenPrinted := cnt.MailWhenPrinted;
end
else
begin
inherited Assign(Source);
end;
end;
constructor TIdLPRControlFile.Create;
begin
inherited Create;
try
HostName := GStack.LocalAddress;
except
HostName:=RSLPRUnknown;
end;
FFileFormat := DEF_FILEFORMAT;
FIndentCount := DEF_INDENTCOUNT;
FBannerPage := DEF_BANNERPAGE;
FOutputWidth := DEF_OUTPUTWIDTH;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -