Re: How to call this function
From: AlanGLLoyd (alanglloyd_at_aol.com)
Date: 12/31/04
- Next message: Jamie: "Re: Software protection"
- Previous message: Rob Kennedy: "Re: Adding "Items" property to component"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 31 Dec 2004 20:49:27 GMT
In article <41d13f3c$0$1682$9b622d9e@news.freenet.de>, "Jürgen Peters"
<JuergenPeters@yahoo.de> writes:
>function FastTagReplace(const SourceString, TagStart, TagEnd: string;
>FastTagReplaceProc: TFastTagReplaceProc; const UserData: Integer): string;
>
>i need to write my own FastTagReplaceProc to modify the tags,
>but i dont know how to include this into my source
>
>can someone help me please?
>
TFastTagReplaceProc has the declaration ...
TFastTagReplaceProc = procedure (var Tag: string; const UserData: Integer);
This is the procedure format that FastTagReplace expects to find - its rather
like an event handler in Delphi.
Tag is the tag it has found as a string between the TagStart and TagEnd strings
(it is not obvious whether the TagStart and TagEnd are included in the returned
Tag) You modify Tag as you wish. UserData is a 4-byte integer which is the same
value as you specified when you called FastTagReplace(). It can be an
identifying value, a reference to an instance of a Delphi class which you may
use or whatever.
Note that the call-back procedure must be a general procedure, not a method of
an object. IE the procedure name is _not_ prefixed with the class name
(TWhatever) as methods are.
FastTagReplace appears to use a Boyer-Moore-Horspool searching algorithm which
is fast.Faster for longer sub-strings than for short ones. It looks for the
_last_ character in the sub-string, when it finds one it seacrhes backward for
all the appropriate characters in the sub-string. If it gets to the first
character in the sub-string it has found an occurence of the whole sub-string.
If not it jumps an appropriate length (the length of the sub-string if all
characters are different) and tries again. You will realise that if the
sub-string was 12 diferent characters long it would check only every 12th
character in the file for equivalence to the last character in the sub-string.
Alan Lloyd
alanglloyd@aol.com
- Next message: Jamie: "Re: Software protection"
- Previous message: Rob Kennedy: "Re: Adding "Items" property to component"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|