📄 unit1.pas
字号:
unit Unit1;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, SctVar, ExtCtrls, SctRep, SctCtrl, AcePage, StdCtrls,
Buttons, SctBtn, DB, DBTables;
type
TForm1 = class(TForm)
SctReport1: TSctReport;
ReportPage: TSctGrouppage;
ReportHeaderBand: TSctBand;
ReportHeaderBandlevel: TSctLevel;
PageHeaderBand: TSctBand;
PageHeaderBandlevel: TSctLevel;
DetailBand: TSctBand;
DetailBandlevel: TSctLevel;
PageFooterBand: TSctBand;
PageFooterBandlevel: TSctLevel;
ReportFooterBand: TSctBand;
ReportFooterBandlevel: TSctLevel;
SctReportButton1: TSctReportButton;
svarDateTime: TSctDateTimeVar;
svarPage: TSctPageVar;
MemoLine: TSctExprVar;
varlabel: TSctvarlabel;
Memo1: TMemo;
Sctvarlabel1: TSctvarlabel;
procedure ReportPageDataStart(Sender: TObject);
procedure ReportPageDataSkip(Sender: TObject);
procedure ReportPageDataFinish(Sender: TObject);
procedure Sctvarlabel1BeforePrint(lb: TSctLabel);
private
{ Private declarations }
StreamSize: LongInt;
Stream: TMemoryStream;
function GetMemoLine: Boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.ReportPageDataStart(Sender: TObject);
begin
Stream := TMemoryStream.Create;
{ Load the text file from the application directory }
Stream.LoadFromFile(ExtractFilePath(Application.ExeName) + '\document.txt');
StreamSize := Stream.Size;
Stream.Position := 0;
{ Get the first line of data }
TSctGroupPage(Sender).DataIsFinished := GetMemoLine;
end;
procedure TForm1.ReportPageDataSkip(Sender: TObject);
begin
{ Get the next line of data until there is none left }
TSctGroupPage(Sender).DataIsFinished := GetMemoLine;
end;
procedure TForm1.ReportPageDataFinish(Sender: TObject);
begin
{ free the stream when we are finished }
Stream.Free;
end;
{
This function will strip out the text from a stream up to a
carraige return or page break. I will return true if there
is nothing left in the stream.
}
function TForm1.GetMemoLine: Boolean;
var
Start,Spot,Len: LongInt;
CopyStream: TMemoryStream;
NextChar: Char;
Done: Boolean;
begin
CopyStream := TMemoryStream.Create;
if Stream.Position < StreamSize then
begin
Result := False;
Done := False;
while Not Done do
begin
Stream.Read(NextChar, 1);
if NextChar = #13 then { do nothing }
else if (NextChar = #10) or (NextChar = #12) then Done := True
else CopyStream.Write(NextChar, 1);
if Stream.Position >= StreamSize then Done := True;
end;
CopyStream.Position := 0;
MemoLine.AsStream := CopyStream;
CopyStream.Free;
end else Result := True;
end;
procedure TForm1.Sctvarlabel1BeforePrint(lb: TSctLabel);
begin
TSctVarLabel(lb).Lines.Assign(Memo1.Lines);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -