Re: How to call this function

From: AlanGLLoyd (alanglloyd_at_aol.com)
Date: 12/31/04


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



Relevant Pages

  • renee.rtf.xab

    (comp.lang.tcl)
  • Re: Introducing bit-part characters
    ... guy one in the crowd, second speaker in the crowd, yet ... it would be out of character not to know. ... little man spoke with the air of a professor calmly lecturing: ... My evil overlords tag people like "the pretty Farseer, ...
    (rec.arts.sf.composition)
  • Re: $_SESSION[variable_name], Invalid XHTML and &amp;
    ... leading character for special character sequences. ... all ampersands should be converted to & ... do any security risks exist? ... I'm seeing that PHP automatically adds an extra tag? ...
    (comp.lang.php)
  • Re: Stripping html
    ... || time looking for a '<' character. ... | to miss finding the "/string" tag. ...
    (comp.lang.c)
  • How to Find Specific Text in a Text String
    ... I have a text string that I want to search for in a column. ... begin at character 1 in the text string. ... to an adjacent cell); regardless of the position of my sub-string within the ...
    (microsoft.public.excel.misc)