Hex Editor
Hex Editor - Binary File Editing Software for Windows

IFileDocument.FindS Method

HHD Software - Hex Editor Serial Port Monitor USB Protocol Analyzer Network Monitor
 
 
 
< PreviousTopNext >
Declaration
Automation:
ulong  FindS ( [in]   ISequence  pSequence, [in]   IMultiSelection  pSelection, [in]   ulong  StartFrom, [in]   bool  search_up, [in]   bool  ignore_case) ;
Native (C++):
HRESULT  FindS ( [in]   ISequence *  pSequence, [in]   IMultiSelection *  pSelection, [in]   unsigned __int64  StartFrom, [in]   BOOL  search_up, [in]   BOOL  ignore_case, [out, retval]   unsigned __int64 *  offset_found) ;
Parameters
pSequenceSequence object containing a find pattern.pSelectionMultiple selection object, which contains ranges in which you want to locate a patternStartFromOffset from which you want to start searchingsearch_upTrue to search backwards and False to search forwardignore_caseTrue to ignore case and False to perform exact matchingoffset_foundPointer to a variable that receives the located pattern offset or -1 if pattern was not found.
Return Value
Automation:Offset of the located pattern or -1 if pattern was not foundNative: S_OK or standard OLE error code.
Remarks

Searches for a pattern within a given selection. This method returns the offset of the matched pattern. To continue searching, call this method again, adjusting StartFrom field appropriately. If pattern is not found in the specified range, -1 is returned. Complexity: linear-time, depending on the file's size and selection's complexity.

This method is a replacement for IFileDocument.Find when used in scripting languages.

Examples

Searching for a pattern

JavascriptCopy Code
var fdoc = new ActiveXObject("FileDocument.FileDocument");
var msec = fdoc.CreateEmptySelection();

fdoc.Open("c:\\temp\\file.txt");
msec.AddRange(0, fdoc.FileSize);  // We'll be searching in a whole file

var pattern = fdoc.CreateSequence();
pattern.AddData(HexBytes, 0x0d, 0x0a); // EOL pattern
var EOL_Offset = fdoc.ToNumber(fdoc.FindS(pattern, msel, 0, false, false));
// ...
// continue searching
EOL_Offset = fdoc.ToNumber(fdoc.FindS(pattern, msel, EOL_Offset + 1, false, false));
    
< PreviousTopNext >
Copyright © 2012 HHD Software. All rights reserved.