Function TWPCustomRtfEdit.FieldLocate(FieldName:string; fieldcommand:string; FromStart:Boolean; Modes:TWPFieldLocateOptions) : TWPTextObj
Unit: WPCTRMemo
Class: WPCTRMemo.TWPCustomRtfEdit
Parameters
-
FieldName:string fieldcommand:string FromStart:Boolean Modes:TWPFieldLocateOptions
Returns
The type of the result value is TWPTextObj.
Description
This functions works a bit similar toFieldLocate can optionally ignore Edit fields. It further more can also compare the 'Source' property with the parameter fieldcommand. The name and the command are not compared if an empty string is passed for the respective parameter.
Both string parameters may also contrain one wildcard chracter "*".
The function will, unlike MoveToField, move the cursor outside of field objects even if the form completion mode is active.
Modes:
wplocDontMoveCursor: Move the cursor to the found position - the screen is never updated. ShowCursor must be called.
wplocGlobalSearch: Search in all texts wplocIgnoreEditFieldsIgnore Editfields
If wplocDontMoveCursor =true the function will use its own paragraph reference to remember the last position for the next call with FromStart=false. This can cause an error in case that paragraph has been deleted between calls to FieldLocate.
This code replaces the contents of a certain group of fields ("AxxxB") with the value 'Test'.
obj := nil;
FromStart := TRUE;
repeat
obj := WPRichText1.FieldLocate('A*B', '', FromStart, [wplocGlobalSearch,wplocDontMoveCursor]);
if obj<>nil then
obj.Embeddedtext := 'Test';
FromStart := FALSE;
until obj = nil;