Hex Editor
Hex Editor - Binary File Editing Software for Windows

IFileDocument.ReplaceAllS Method

HHD Software - Hex Editor Serial Port Monitor USB Protocol Analyzer Network Monitor
 
 
 
< PreviousTopNext >
Declaration
Automation:
ulong  ReplaceAllS ( [in]   ISequence  pSequenceFrom, [in]   ISequence  pSequenceTo, [in]   bool  ignore_case, [in]   IMultiSelection  pSelection) ;
Native (C++):
HRESULT  ReplaceAllS ( [in]   ISequence *  pSequenceFrom, [in]   ISequence *  pSequenceTo, [in]   BOOL  ignore_case, [in]   IMultiSelection *  pSelection, [out, retval]   unsigned __int64 *  pReplaced) ;
Parameters
pSequenceFromSequence object containing a find pattern.pSequenceToSequence object containing a replace pattern.ignore_caseTrue to ignore case, False to perform exact matchingpSelectionMultiple Selection object, describing the ranges in which to perform search and replacepReplacedPointer to a variable that receives the number of replacements done.
Return Value
Automation:A number of replacements done.Native: S_OK or standard OLE error code.
Remarks

Finds and replaces all occurrences of the given pattern with another pattern. Complexity: varying.

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

Examples

Searching all pattern occurrences

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

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

var pattern1 = fdoc.CreateSequence();
var pattern2 = fdoc.CreateSequence();
pattern1.AddData(HexBytes, 0x0d, 0x0a); // EOL pattern
pattern2.AddData(HexBytes, 0x0d, 0x0a, 0x0d, 0x0a); // Double-EOL pattern
var nReplacements = fdoc.ToNumber(fdoc.ReplaceAllS(pattern1, pattern2, false, msel);
    
< PreviousTopNext >
Copyright © 2012 HHD Software. All rights reserved.