?? 2.pas
字號:
fuction IsDelimiter(aCh : Char; const aDelims : string) : boolean;
var
i : integer;
begin
Result := true;
if (aCh > ' ') then
begin
for i := 1 to length(aDelims) do
if (aDellims[i] = aCh then Exit;
Result := false;
end;
end;
procedure AAParseWords(aText : TStream; const aDelims : string; aAction : TaaWordParseAction);
const
BufSize = 16 * 1024;
var
State : (ScanWord , ScanOther);
Buffer : PChar;
BufPos : PChar;
BufLeft : integer;
Ch : char;
StopNow : boolean;
CharQ : TaaCharQueue;
begin
//perpare for the memory allocations
Buffer := nil;
CharQ := nil;
try
//create a character queue with which to bulid words
CharQ := TaaCharQueue.Create;
//allocate a buffer to hold data from the stream
GetMem(Buffer , BufferSize);
//force the stream to be read first time through
BufLeft := 1;
BufPos := Buffer;
//we'll start in the scanning delimiter state
State := ScanOther;
StopNow := false;
//continue until there is no more data in the stream
while (not StopNow) and (BufLeft <> 0) do
begin
//advance the buffer variables (reading more data if needed)
dec(BufLeft);
if (BufLeft <> 0) then
inc(BufPos)
else
begin
BufLeft := aText.Read(Buffer^ , BufSize);
BufPos := Buffer;
end;
//get the next character
Ch := BufPos^;
//process the character according to the state
case State of
ScanWord :
begin
if IsDelimiter(Ch , aDelims) then
begin
aAction(CharQ.AsString , StopNow);
State := ScanOther;
end
else
CharQ.Append(Ch);
end;
ScanOther :
begin
if not IsDelimiter(Ch , aDelims) then
begin
CharQ.Clear;
CharQ.Append(Ch);
State := ScanWord;
end;
end;
end;
end;
finally
if (Buffer <> nil) then
FreeMem(Buffer);
CharQ.Free;
end;
end;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -