This interface is implemented by File Document Object. See the Creating File Document Object section to see how you create the object in your code.
interface IFileDocument extends ${IDispatch} {
// Properties
${AutoCreateBranch}: boolean;
readonly ${FileName}: string;
${FileSize}: number;
readonly ${Modified}: boolean;
readonly ${Stream}: boolean;
readonly ${ReadOnly}: boolean;
${RegExpSyntaxError}: string;
readonly ${CanRedo}: boolean;
readonly ${CanUndo}: boolean;
readonly ${CanPaste}: boolean;
// Methods
${Close}(): void;
${New}(): void;
${Open}(Name: string, ReadOnly: boolean): void;
${OpenPhysicalDisk}(PhysicalDiskName: string, FriendlyName: string, ReadOnly: boolean): void;
${OpenProcess}(ProcessId: number, Start: number, Size: number, ReadOnly: boolean): void;
${OpenVolume}(VolumeName: string, FriendlyName: string, ReadOnly: boolean): void;
${Save}(ForceBackup: boolean): void;
${SaveAs}(FileName: string): void;
${GetModifiedSel}(Selection: ${IMultiSelection}): void;
${Decrypt}(Provider: string,
ProviderType: number,
AlgoID: number,
Password: string,
Selection: ${IMultiSelection},
KeyLength?: number): void;
${Delete}(Offset: number, Size: number): void;
${DeleteMulti}(Selection: ${IMultiSelection}): void;
${Encrypt}(Provider: string,
ProviderType: number,
AlgoID: number,
Password: string,
Selection: ${IMultiSelection},
KeyLength?: number): void;
${FillByte}(FillValue: number, Offset: number, Size: number): void;
${FillByteMulti}(FillValue: number, Selection: ${IMultiSelection}): void;
${InsertByte}(ByteFill: number, Offset: number, Size: number): void;
${PutFile}(FileName: string, Offset: , InsertMode: boolean): void;
${CreatePatch}(PatchName: string, Options: ${PatchOptions}, PathToStubFile?: string): void;
${Purge}(Level: ${HistoryPurgeLevel}): void;
${Redo}(Steps?: number): void;
${Undo}(Steps?: number): void;
${Copy}(Selection: ${IMultiSelection}, MergeBlocks: boolean): void;
${Cut}(Selection: ${IMultiSelection}, MergeBlocks: boolean): void;
${Paste}(Offset: number, InsertMode: boolean): void;
${Paste2}(Offset: number, Type: ${TextType}, InsertMode: boolean): void;
${Paste3}(Offset: number, Type: ${TextType}, Flags: ${Paste3Flags}): void;
${PasteText}(Offset: number, Unicode: boolean, InsertMode: boolean): void;
${PasteText2}(Offset: number, CodePage: number, InsertMode: boolean): void;
${FindAllRegExp}(RegExp: string,
SubExpression: number,
Flags: ${RegExpFlags},
StartFrom: number,
Size: number,
Found: ${IMultiSelection}): void;
${FindAllRegExp2}(RegExp: string,
CodePage: number,
SubExpression: number,
Flags: ${RegExpFlags},
StartFrom: number,
Size: number,
Found: ${IMultiSelection}): void;
${ReplaceAllRegExpWithRegExp}(RegExp: string,
ReplacePattern: string,
CodePage: number,
Flags: ${RegExpFlags},
StartFrom: number,
Size: number): void;
${Gap}(pSelection: ${IMultiSelection}): void;
${ArithmeticOp}(Selection: ${IMultiSelection},
Type: ${ArithmeticOpType},
OpSize: ${OperandSizeType},
Operand?: any): void;
${CaseOp}(Selection: ${IMultiSelection},
Type: ${CaseOpType},
Unicode: boolean,
CodePage?: number): void;
${ShiftOp}(Selection: ${IMultiSelection}, Type: ${ShiftOpType}, OpSize: , Bits: number): void;
${ReverseOp}(Selection: ${IMultiSelection}, Type: ${ReverseOpType}, OpSize: ${OperandSizeType}): void;
${CreateEmptySelection}(): ${IMultiSelection};
${CreateSequence}(): ${ISequence};
${BitwiseOpS}(Selection: ${IMultiSelection}, Type: ${BitwiseOpType}, Sequence: ${ISequence}): void;
${FillMultiS}(Sequence: ${ISequence}, Selection: ${IMultiSelection}, Continue: boolean): void;
${FillS}(Sequence: ${ISequence}, Offset: number, Size: number): void;
${FindAllS}(Sequence: ${ISequence},
Selection: ${IMultiSelection},
IgnoreCase: boolean,
Found: ${IMultiSelection}): void;
${FindS}(Sequence: ${ISequence},
Selection: ${IMultiSelection},
StartFrom: number,
SearchUp: boolean,
IgnoreCase: boolean): void;
${InsertPatternS}(Sequence: ${ISequence}, Offset: number, Size: number): void;
${InsertS}(Sequence: ${ISequence}, Offset: number): void;
${ReadS}(Sequence: ${ISequence}, Offset: number): void;
${ReplaceAllRegExpS}(RegExp: string,
SubExpression: number,
Flags: ${RegExpFlags},
Sequence: ${ISequence},
StartFrom: number,
Size: number): void;
${ReplaceAllRegExp2S}(RegExp: string,
CodePage: number,
SubExpression: number,
Flags: ${RegExpFlags},
Sequence: ${ISequence},
StartFrom: number,
Size: number): void;
${ReplaceAllS}(SequenceFrom: ${ISequence},
SequenceTo: ${ISequence},
IgnoreCase: boolean,
Selection: ${IMultiSelection}): void;
${ReplaceS}(Offset: number, Size: number, Sequence: ${ISequence}): void;
${ToNumber}(Value: any): number;
${WriteS}(Sequence: ${ISequence}, Offset: number): void;
}
public interface IFileDocument : ${IDispatch}
{
// Properties
bool ${AutoCreateBranch} { get; set; }
string ${FileName} { get; }
ulong ${FileSize} { get; set; }
bool ${Modified} { get; }
bool ${Stream} { get; }
bool ${ReadOnly} { get; }
string ${RegExpSyntaxError} { get; set; }
bool ${CanRedo} { get; }
bool ${CanUndo} { get; }
bool ${CanPaste} { get; }
// Methods
void ${Close}();
void ${New}();
void ${Open}(string Name, bool ReadOnly);
void ${OpenPhysicalDisk}(string PhysicalDiskName, string FriendlyName, bool ReadOnly);
void ${OpenProcess}(uint ProcessId, long Start, ulong Size, bool ReadOnly);
void ${OpenVolume}(string VolumeName, string FriendlyName, bool ReadOnly);
void ${Save}(bool ForceBackup);
void ${SaveAs}(string FileName);
void ${GetModifiedSel}(${IMultiSelection} Selection);
void ${Decrypt}(string Provider,
uint ProviderType,
uint AlgoID,
string Password,
${IMultiSelection} Selection,
uint KeyLength);
void ${Delete}(ulong Offset, ulong Size);
void ${DeleteMulti}(${IMultiSelection} Selection);
void ${Encrypt}(string Provider,
uint ProviderType,
uint AlgoID,
string Password,
${IMultiSelection} Selection,
uint KeyLength);
void ${Fill}(ref byte Pattern,
uint PatternSize,
ulong Offset,
ulong Size);
void ${FillByte}(byte FillValue, ulong Offset, ulong Size);
void ${FillByteMulti}(byte FillValue, ${IMultiSelection} Selection);
void ${FillMulti}(ref byte Pattern, uint PatternSize, ${IMultiSelection} Selection, Continue);
void ${Insert}(ref byte Data, ulong Offset, uint InsertSize);
void ${InsertByte}(byte ByteFill, ulong Offset, ulong Size);
void ${InsertPattern}(ref byte Pattern,
uint PatternSize,
ulong Offset,
ulong Size);
void ${PutFile}(string FileName, ulong Offset, bool InsertMode);
void ${Read}(ref byte Data, ulong Offset, uint ReadSize);
void ${Write}(ref byte Data, ulong Offset, uint WriteSize);
void ${CreatePatch}(string PatchName, ${PatchOptions} Options, string PathToStubFile);
void ${LoadHistory}(IStream Stream);
void ${Purge}(${HistoryPurgeLevel} Level);
void ${Redo}(uint Steps);
void ${SaveHistory}(IStream Stream);
void ${Undo}(uint Steps);
void ${Copy}(${IMultiSelection} Selection, bool MergeBlocks);
void ${Cut}(${IMultiSelection} Selection, bool MergeBlocks);
void ${Paste}(ulong Offset, bool InsertMode);
void ${Paste2}(ulong Offset, ${TextType} Type, bool InsertMode);
void ${Paste3}(ulong Offset, ${TextType} Type, ${Paste3Flags} Flags);
void ${PasteText}(ulong Offset, bool Unicode, bool InsertMode);
void ${PasteText2}(ulong Offset, uint CodePage, bool InsertMode);
ulong ${Find}(ref byte DataToFind,
uint DataSize,
${IMultiSelection} Selection,
ulong StartFrom,
bool SearchUp,
bool ignore_case);
void ${FindRegExp}(string RegExp,
uint SubExpression,
${RegExpFlags} Flags,
ulong StartFrom,
ulong Size,
ref ulong FoundOffset,
ref ulong MatchSize);
void ${FindRegExp2}(string RegExp,
uint CodePage,
uint SubExpression,
${RegExpFlags} Flags,
ulong StartFrom,
ulong Size,
ref ulong FoundOffset,
ref ulong MatchSize);
void ${FindAll}(ref byte DataToFind,
uint DataSize,
${IMultiSelection} Selection,
bool IgnoreCase,
${IMultiSelection} Found);
void ${FindAllRegExp}(string RegExp,
uint SubExpression,
${RegExpFlags} Flags,
ulong StartFrom,
ulong Size,
${IMultiSelection} Found);
void ${FindAllRegExp2}(string RegExp,
uint CodePage,
uint SubExpression,
${RegExpFlags} Flags,
ulong StartFrom,
ulong Size,
${IMultiSelection} Found);
void ${Replace}(ulong Offset,
uint SizeFrom,
ref byte To,
uint SizeTo);
void ${ReplaceAll}(ref byte From,
uint SizeFrom,
ref byte To,
uint SizeTo,
bool IgnoreCase,
${IMultiSelection} Selection);
void ${ReplaceAllRegExp}(string RegExp,
uint SubExpression,
${RegExpFlags} Flags,
ref byte To,
uint SizeTo,
ulong StartFrom,
ulong Size);
void ${ReplaceAllRegExp2}(string RegExp,
uint CodePage,
uint SubExpression,
${RegExpFlags} Flags,
ref byte To,
uint SizeTo,
ulong StartFrom,
ulong Size);
void ${ReplaceAllRegExpWithRegExp}(string RegExp,
string ReplacePattern,
uint CodePage,
${RegExpFlags} Flags,
ulong StartFrom,
ulong Size);
void ${Gap}(${IMultiSelection} pSelection);
void ${ArithmeticOp}(${IMultiSelection} Selection,
${ArithmeticOpType} Type,
${OperandSizeType} OpSize,
object Operand);
void ${BitwiseOp}(${IMultiSelection} Selection, ${BitwiseOpType} Type, ref byte Data, uint DataSize);
void ${CaseOp}(${IMultiSelection} Selection,
${CaseOpType} Type,
bool Unicode,
object CodePage);
void ${ShiftOp}(${IMultiSelection} Selection, ${ShiftOpType} Type, OpSize, uint Bits);
void ${ReverseOp}(${IMultiSelection} Selection, ${ReverseOpType} Type, ${OperandSizeType} OpSize);
ulong[] ${GatherStatistics}(${IMultiSelection} Selection);
void ${PatternStatistics}(ref byte Pattern,
uint DataSize,
bool IgnoreCase,
ref ulong DataBuffer,
uint Blocks,
${IMultiSelection} Selection);
void ${PatternStatisticsRegExp}(string RegExp,
uint SubExpression,
${RegExpFlags} Flags,
ref ulong DataBuffer,
uint Blocks,
ulong StartFrom,
ulong Size);
void ${PatternStatisticsRegExp2}(string RegExp,
uint CodePage,
uint SubExpression,
${RegExpFlags} Flags,
ref ulong DataBuffer,
uint Blocks,
ulong StartFrom,
ulong Size);
${IMultiSelection} ${CreateEmptySelection}();
${ISequence} ${CreateSequence}();
}
struct IFileDocument : IDispatch
{
// Properties
VARIANT_BOOL ${AutoCreateBranch}; // get set
_bstr_t ${FileName}; // get
unsigned long long ${FileSize}; // get set
VARIANT_BOOL ${Modified}; // get
VARIANT_BOOL ${Stream}; // get
VARIANT_BOOL ${ReadOnly}; // get
_bstr_t ${RegExpSyntaxError}; // get set
VARIANT_BOOL ${CanRedo}; // get
VARIANT_BOOL ${CanUndo}; // get
VARIANT_BOOL ${CanPaste}; // get
// Methods
HRESULT ${Close}();
HRESULT ${New}();
HRESULT ${Open}(_bstr_t Name, VARIANT_BOOL ReadOnly);
HRESULT ${OpenPhysicalDisk}(_bstr_t PhysicalDiskName, _bstr_t FriendlyName, VARIANT_BOOL ReadOnly);
HRESULT ${OpenProcess}(unsigned long ProcessId, long long Start, unsigned long long Size, VARIANT_BOOL ReadOnly);
HRESULT ${OpenVolume}(_bstr_t VolumeName, _bstr_t FriendlyName, VARIANT_BOOL ReadOnly);
HRESULT ${Save}(VARIANT_BOOL ForceBackup);
HRESULT ${SaveAs}(_bstr_t FileName);
HRESULT ${GetModifiedSel}(${IMultiSelectionPtr#IMultiSelection} Selection);
HRESULT ${Decrypt}(_bstr_t Provider,
unsigned long ProviderType,
unsigned long AlgoID,
_bstr_t Password,
${IMultiSelectionPtr#IMultiSelection} Selection,
_variant_t KeyLength);
HRESULT ${Delete}(unsigned long long Offset, unsigned long long Size);
HRESULT ${DeleteMulti}(${IMultiSelectionPtr#IMultiSelection} Selection);
HRESULT ${Encrypt}(_bstr_t Provider,
unsigned long ProviderType,
unsigned long AlgoID,
_bstr_t Password,
${IMultiSelectionPtr#IMultiSelection} Selection,
_variant_t KeyLength);
HRESULT ${Fill}(unsigned char * Pattern,
unsigned long PatternSize,
unsigned long long Offset,
unsigned long long Size);
HRESULT ${FillByte}(unsigned char FillValue, unsigned long long Offset, unsigned long long Size);
HRESULT ${FillByteMulti}(unsigned char FillValue, ${IMultiSelectionPtr#IMultiSelection} Selection);
HRESULT ${FillMulti}(unsigned char * Pattern, unsigned long PatternSize, ${IMultiSelectionPtr#IMultiSelection} Selection, Continue);
HRESULT ${Insert}(unsigned char * Data, unsigned long long Offset, unsigned long InsertSize);
HRESULT ${InsertByte}(unsigned char ByteFill, unsigned long long Offset, unsigned long long Size);
HRESULT ${InsertPattern}(unsigned char * Pattern,
unsigned long PatternSize,
unsigned long long Offset,
unsigned long long Size);
HRESULT ${PutFile}(_bstr_t FileName, unsigned long long Offset, VARIANT_BOOL InsertMode);
HRESULT ${Read}(unsigned char * Data, unsigned long long Offset, unsigned long ReadSize);
HRESULT ${Write}(unsigned char * Data, unsigned long long Offset, unsigned long WriteSize);
HRESULT ${CreatePatch}(_bstr_t PatchName, ${PatchOptions} Options, _variant_t PathToStubFile);
HRESULT ${LoadHistory}(IStream * Stream);
HRESULT ${Purge}(${HistoryPurgeLevel} Level);
HRESULT ${Redo}(_variant_t Steps);
HRESULT ${SaveHistory}(IStream * Stream);
HRESULT ${Undo}(_variant_t Steps);
HRESULT ${Copy}(${IMultiSelectionPtr#IMultiSelection} Selection, VARIANT_BOOL MergeBlocks);
HRESULT ${Cut}(${IMultiSelectionPtr#IMultiSelection} Selection, VARIANT_BOOL MergeBlocks);
HRESULT ${Paste}(unsigned long long Offset, VARIANT_BOOL InsertMode);
HRESULT ${Paste2}(unsigned long long Offset, ${TextType} Type, VARIANT_BOOL InsertMode);
HRESULT ${Paste3}(unsigned long long Offset, ${TextType} Type, ${Paste3Flags} Flags);
HRESULT ${PasteText}(unsigned long long Offset, VARIANT_BOOL Unicode, VARIANT_BOOL InsertMode);
HRESULT ${PasteText2}(unsigned long long Offset, unsigned long CodePage, VARIANT_BOOL InsertMode);
unsigned long long ${Find}(unsigned char * DataToFind,
unsigned long DataSize,
${IMultiSelectionPtr#IMultiSelection} Selection,
unsigned long long StartFrom,
VARIANT_BOOL SearchUp,
VARIANT_BOOL ignore_case);
HRESULT ${FindRegExp}(_bstr_t RegExp,
unsigned long SubExpression,
${RegExpFlags} Flags,
unsigned long long StartFrom,
unsigned long long Size,
unsigned long long * FoundOffset,
unsigned long long * MatchSize);
HRESULT ${FindRegExp2}(_bstr_t RegExp,
unsigned long CodePage,
unsigned long SubExpression,
${RegExpFlags} Flags,
unsigned long long StartFrom,
unsigned long long Size,
unsigned long long * FoundOffset,
unsigned long long * MatchSize);
HRESULT ${FindAll}(unsigned char * DataToFind,
unsigned long DataSize,
${IMultiSelectionPtr#IMultiSelection} Selection,
VARIANT_BOOL IgnoreCase,
${IMultiSelectionPtr#IMultiSelection} Found);
HRESULT ${FindAllRegExp}(_bstr_t RegExp,
unsigned long SubExpression,
${RegExpFlags} Flags,
unsigned long long StartFrom,
unsigned long long Size,
${IMultiSelectionPtr#IMultiSelection} Found);
HRESULT ${FindAllRegExp2}(_bstr_t RegExp,
unsigned long CodePage,
unsigned long SubExpression,
${RegExpFlags} Flags,
unsigned long long StartFrom,
unsigned long long Size,
${IMultiSelectionPtr#IMultiSelection} Found);
HRESULT ${Replace}(unsigned long long Offset,
unsigned long SizeFrom,
unsigned char * To,
unsigned long SizeTo);
HRESULT ${ReplaceAll}(unsigned char * From,
unsigned long SizeFrom,
unsigned char * To,
unsigned long SizeTo,
VARIANT_BOOL IgnoreCase,
${IMultiSelectionPtr#IMultiSelection} Selection);
HRESULT ${ReplaceAllRegExp}(_bstr_t RegExp,
unsigned long SubExpression,
${RegExpFlags} Flags,
unsigned char To,
unsigned long SizeTo,
unsigned long long StartFrom,
unsigned long long Size);
HRESULT ${ReplaceAllRegExp2}(_bstr_t RegExp,
unsigned long CodePage,
unsigned long SubExpression,
${RegExpFlags} Flags,
unsigned char * To,
unsigned long SizeTo,
unsigned long long StartFrom,
unsigned long long Size);
HRESULT ${ReplaceAllRegExpWithRegExp}(_bstr_t RegExp,
_bstr_t ReplacePattern,
unsigned long CodePage,
${RegExpFlags} Flags,
unsigned long long StartFrom,
unsigned long long Size);
void ${Gap}(${IMultiSelection} pSelection);
HRESULT ${ArithmeticOp}(${IMultiSelectionPtr#IMultiSelection} Selection,
${ArithmeticOpType} Type,
${OperandSizeType} OpSize,
_variant_t Operand);
HRESULT ${BitwiseOp}(${IMultiSelectionPtr#IMultiSelection} Selection, ${BitwiseOpType} Type, unsigned char * Data, unsigned long DataSize);
HRESULT ${CaseOp}(${IMultiSelectionPtr#IMultiSelection} Selection,
${CaseOpType} Type,
VARIANT_BOOL Unicode,
_variant_t CodePage);
HRESULT ${ShiftOp}(${IMultiSelectionPtr#IMultiSelection} Selection, ${ShiftOpType} Type, OpSize, unsigned long Bits);
HRESULT ${ReverseOp}(${IMultiSelectionPtr#IMultiSelection} Selection, ${ReverseOpType} Type, ${OperandSizeType} OpSize);
unsigned long long[256] ${GatherStatistics}(${IMultiSelectionPtr#IMultiSelection} Selection);
HRESULT ${PatternStatistics}(unsigned char * Pattern,
unsigned long DataSize,
VARIANT_BOOL IgnoreCase,
unsigned long long * DataBuffer,
unsigned long Blocks,
${IMultiSelectionPtr#IMultiSelection} Selection);
HRESULT ${PatternStatisticsRegExp}(_bstr_t RegExp,
unsigned long SubExpression,
${RegExpFlags} Flags,
unsigned long long * DataBuffer,
unsigned long Blocks,
unsigned long long StartFrom,
unsigned long long Size);
HRESULT ${PatternStatisticsRegExp2}(_bstr_t RegExp,
unsigned long CodePage,
unsigned long SubExpression,
${RegExpFlags} Flags,
unsigned long long * DataBuffer,
unsigned long Blocks,
unsigned long long StartFrom,
unsigned long long Size);
${IMultiSelectionPtr#IMultiSelection} ${CreateEmptySelection}();
${ISequencePtr#ISequence} ${CreateSequence}();
};
AutoCreateBranch: boolean;
bool AutoCreateBranch { get; set; }
VARIANT_BOOL AutoCreateBranch; // get set
true
if Auto Create Branches option enabled, false
otherwise.
Query or set the AutoCreateBranch property value. See the History » Auto Create Branches switch description for more information about this property.
readonly FileName: string;
string FileName { get; }
_bstr_t FileName; // get
The full file's path name.
Using the FileName property
var fdoc=new ActiveXObject("FileDocument.FileDocument");
fdoc.Open("c:\\temp\\file.bin");
alert("Full file name is " + fdoc.FileName);
FileSize: number;
ulong FileSize { get; set; }
unsigned long long FileSize; // get set
Retrieve or change the current file's size. When used to change the file's size, new operation is created in document's operation history.
Complexity: constant-time.
Setting file's size
var fdoc = new ActiveXObject("FileDocument.FileDocument");
fdoc.New(); // initialize a new, empty document
fdoc.FileSize = 1024*1024; // set the size of the file to 1 MB
fdoc.SaveAs("c:\\temp\\file.bin");
readonly Modified: boolean;
bool Modified { get; }
VARIANT_BOOL Modified; // get
Returns the modified document state.
readonly Stream: boolean;
bool Stream { get; }
VARIANT_BOOL Stream; // get
This property is true
if document represents an NTFS stream and false
otherwise.
readonly ReadOnly: boolean;
bool ReadOnly { get; }
VARIANT_BOOL ReadOnly; // get
Retrieves the document's ReadOnly state.
RegExpSyntaxError: string;
string RegExpSyntaxError { get; set; }
_bstr_t RegExpSyntaxError; // get set
Returns a textual representation (in English) of a regular expression syntax error, if any.
readonly CanRedo: boolean;
bool CanRedo { get; }
VARIANT_BOOL CanRedo; // get
Determine if you can call the IFileDocument.Redo method.
Sample implementation of the Redo method
void Redo(IFileDocument *pFileDocument)
{
VARIANT_BOOL bCanRedo;
pFileDocument->get_CanRedo(&bCanRedo);
if (bCanRedo == VARIANT_TRUE)
pFileDocument->Redo();
}
Sample implementation of the Redo method
public void Redo(IFileDocument fdoc)
{
if (fdoc.CanRedo)
fdoc.Redo();
}
readonly CanUndo: boolean;
bool CanUndo { get; }
VARIANT_BOOL CanUndo; // get
Determine if you can call the IFileDocument.Undo method.
Sample implementation of the Undo method
void Undo(IFileDocument *pFileDocument)
{
VARIANT_BOOL bCanUndo;
pFileDocument->get_CanUndo(&bCanUndo);
if (bCanUndo == VARIANT_TRUE)
pFileDocument->Undo();
}
Sample implementation of the Undo method
public void Undo(IFileDocument fdoc)
{
if (fdoc.CanUndo)
fdoc.Undo();
}
readonly CanPaste: boolean;
bool CanPaste { get; }
VARIANT_BOOL CanPaste; // get
Determine if you can paste data from the Clipboard.
// pFileDocument is initialized elsewhere
VARIANT_BOOL bCanPaste;
pFileDocument->get_CanPaste(&bCanPaste);
if (bCanPaste != VARIANT_FALSE)
{
// Clipboard contains compatible data
} else
{
// Clipboard contains incompatible data
}
Close(): void;
void Close();
HRESULT Close();
Discard document's operation history and close the document. You may subsequently call the IFileDocument.New or IFileDocument.Open method for this document.
Complexity: constant-time.
Reusing document objects
var fdoc = new FileDocumentLib.FileDocument();
fdoc.Open(@"c:\temp\file1");
// perform modifications to the file and save it
fdoc.Save(false);
// prepare the object to work with a next document
fdoc.Close();
fdoc.Open(@"c:\temp\file2");
// ...
New(): void;
void New();
HRESULT New();
Creates a new, empty document.
Complexity: constant-time.
Open(Name: string, ReadOnly: boolean): void;
void Open(string Name, bool ReadOnly);
HRESULT Open(_bstr_t Name, VARIANT_BOOL ReadOnly);
Name
ReadOnly
Opens an existing document. Hex Editor Neo tries to get a read-only access to the file. It also denies write access to all future open attempts, until the file is closed.
Complexity: constant-time.
If supported by the file system, the name may be actually the name of the alternate data stream. Hex Editor Neo fully supports NTFS alternate data streams. You may use any method provided by the object after opening the file stream. Note however, that there are few limitations that are described in the IFileDocument.Save method section.
Opening a document
var fdoc = new FileDocumentLib.FildDocument();
fdoc.Open(@"\\server\share\somefile.bin", false);
OpenPhysicalDisk(PhysicalDiskName: string, FriendlyName: string, ReadOnly: boolean): void;
void OpenPhysicalDisk(string PhysicalDiskName, string FriendlyName, bool ReadOnly);
HRESULT OpenPhysicalDisk(_bstr_t PhysicalDiskName, _bstr_t FriendlyName, VARIANT_BOOL ReadOnly);
PhysicalDiskName
\\.\PhysicalDriveN
, where N
is a physical disk number (starting from 0).FriendlyName
ReadOnly
true
to open a disk as read-only, or false
otherwise.Open physical disk.
OpenProcess(ProcessId: number, Start: number, Size: number, ReadOnly: boolean): void;
void OpenProcess(uint ProcessId, long Start, ulong Size, bool ReadOnly);
HRESULT OpenProcess(unsigned long ProcessId, long long Start, unsigned long long Size, VARIANT_BOOL ReadOnly);
ProcessId
Start
Size
ReadOnly
true
to disable the Save command, false
otherwise.Open process memory.
OpenVolume(VolumeName: string, FriendlyName: string, ReadOnly: boolean): void;
void OpenVolume(string VolumeName, string FriendlyName, bool ReadOnly);
HRESULT OpenVolume(_bstr_t VolumeName, _bstr_t FriendlyName, VARIANT_BOOL ReadOnly);
VolumeName
\\.\c:
to open a drive letter, or a full volume mount point name.FriendlyName
ReadOnly
true
to open a volume as read-only, or false
otherwise.Open a volume (logical disk).
Save(ForceBackup: boolean): void;
void Save(bool ForceBackup);
HRESULT Save(VARIANT_BOOL ForceBackup);
ForceBackup
Saves all document's changes and drop document's operation history. IFileDocument.FileName property must not be empty to successfully call this method. In particular, the Save method may not be called after the IFileDocument.New method. IFileDocument.SaveAs method always set the IFileDocument.FileName property, so you may call the Save method after the SaveAs method was once called for a document.
ForceBackup
parameter is ignored (assumed to be false
) if the current object represents the NTFS alternate data stream, physical disk, volume, process virtual memory or physical memory.
SaveAs(FileName: string): void;
void SaveAs(string FileName);
HRESULT SaveAs(_bstr_t FileName);
FileName
Saves the file with a different name. The Save As command does not drop a document's operation history. Passing the name of an NTFS alternate data stream to this method is an error and leads to undefined behavior.
To save a document to alternate data stream, first create a stream (this function is outside the scope of this library), open the File Document Object for created stream and use the IFileDocument.Copy and IFileDocument.Paste methods to copy the contents. Then call the created object's IFileDocument.Save method to apply changes.
GetModifiedSel(Selection: ${IMultiSelection}): void;
void GetModifiedSel(${IMultiSelection} Selection);
HRESULT GetModifiedSel(${IMultiSelectionPtr#IMultiSelection} Selection);
Selection
Fills a provided Multiple Selection object with ranges that describe the changed data in the document. The method clears the given multiple selection object before execution.
Complexity: linear-time, depending on the number of document modifications.
Using GetModifiedSel method
var fdoc = new FileDocumentLib.FileDocument();
fdoc.Open(@"c:\temp\file.bin");
fdoc.${FillByte#IFileDocument.FillByte}(0x35, 100, 20);
fdoc.FillByte(0x36, 200, 30);
var msel = fdoc.${CreateEmptySelection#IFileDocument.CreateEmptySelection}();
fdoc.GetModifiedSel(msel);
// msel is now: [100..120) U [200..230)
Decrypt(Provider: string,
ProviderType: number,
AlgoID: number,
Password: string,
Selection: ${IMultiSelection},
KeyLength?: number): void;
void Decrypt(string Provider,
uint ProviderType,
uint AlgoID,
string Password,
${IMultiSelection} Selection,
uint KeyLength);
HRESULT Decrypt(_bstr_t Provider,
unsigned long ProviderType,
unsigned long AlgoID,
_bstr_t Password,
${IMultiSelectionPtr#IMultiSelection} Selection,
_variant_t KeyLength);
Provider
ProviderType
AlgoID
Password
Selection
KeyLength
Decrypt the contents of the document.
Delete(Offset: number, Size: number): void;
void Delete(ulong Offset, ulong Size);
HRESULT Delete(unsigned long long Offset, unsigned long long Size);
Offset
Size
Deletes the given range from the document.
Complexity: constant-time.
Deleting document's data
CComPtr<IFileDocument> pFileDocument;
if (SUCCEEDED(pFileDocument.CoCreateInstance(L"FileDocument.FileDocument")))
{
if (SUCCEEDED(pFileDocument->${Open#IFileDocument.Open}(L"c:\\temp\\file.bin", VARIANT_FALSE)))
{
pFileDocument->Delete(0x50, 0x2a);
pFileDocument->${Save#IFileDocument.Save}(false);
}
}
DeleteMulti(Selection: ${IMultiSelection}): void;
void DeleteMulti(${IMultiSelection} Selection);
HRESULT DeleteMulti(${IMultiSelectionPtr#IMultiSelection} Selection);
Selection
Deletes the given multiple selection from the document.
Complexity: linear-time, depending on the selection's complexity.
Deleting document's data
CComPtr<IFileDocument> pFileDocument;
if (SUCCEEDED(pFileDocument.CoCreateInstance(L"FileDocument.FileDocument")))
{
if (SUCCEEDED(pFileDocument->Open(L"c:\\temp\\file.bin", VARIANT_FALSE)))
{
CComPtr<IMultiSelection> pMultiSelection;
if (SUCCEEDED(pFileDocument->CreateEmptySelection(&pMultiSelection)))
{
pMultiSelection->${AddRange#IMultiSelection.AddRange}(100, 20);
pMultiSelection->${AddRange#IMultiSelection.AddRange}(200, 30);
pFileDocument->DeleteMulti(pMultiSelection);
pFileDocument->Save(false);
}
}
}
Encrypt(Provider: string,
ProviderType: number,
AlgoID: number,
Password: string,
Selection: ${IMultiSelection},
KeyLength?: number): void;
void Encrypt(string Provider,
uint ProviderType,
uint AlgoID,
string Password,
${IMultiSelection} Selection,
uint KeyLength);
HRESULT Encrypt(_bstr_t Provider,
unsigned long ProviderType,
unsigned long AlgoID,
_bstr_t Password,
${IMultiSelectionPtr#IMultiSelection} Selection,
_variant_t KeyLength);
Provider
ProviderType
AlgoID
Password
Selection
KeyLength
Decrypt the contents of the document.
// This method is not available in scripting environment
void Fill(ref byte Pattern,
uint PatternSize,
ulong Offset,
ulong Size);
HRESULT Fill(unsigned char * Pattern,
unsigned long PatternSize,
unsigned long long Offset,
unsigned long long Size);
Pattern
PatternSize
Offset
Size
Fills a given range with a given pattern. A pattern is repeated until the required number of bytes is written to the file. If file is shorter than the filling range, the file's size is increased.
Complexity: constant-time.
Filling a range with a simple pattern
// pFileDocument is initialized elsewhere
unsigned char Pattern[]="Simple Pattern";
HRESULT hRes = pFileDocument->Fill(Pattern, sizeof(Pattern) - 1, 0x10000i64, 0x10ffi64);
FillByte(FillValue: number, Offset: number, Size: number): void;
void FillByte(byte FillValue, ulong Offset, ulong Size);
HRESULT FillByte(unsigned char FillValue, unsigned long long Offset, unsigned long long Size);
FillValue
Offset
Size
Fills a given range with a single byte value.
Complexity: constant-time.
Filling a range with a single byte
// fdoc is initialized elsewhere
fdoc.FillByte(0x34, 1000, 200);
FillByteMulti(FillValue: number, Selection: ${IMultiSelection}): void;
void FillByteMulti(byte FillValue, ${IMultiSelection} Selection);
HRESULT FillByteMulti(unsigned char FillValue, ${IMultiSelectionPtr#IMultiSelection} Selection);
FillValue
Selection
Fills a given multiple selection with a single byte value.
Complexity: linear-time, depending on the selection's complexity.
Filling a range with a single byte
// fdoc is initialized elsewhere
var msel = fdoc.${CreateEmptySelection#IFileDocument.CreateEmptySelection}();
msel.${AddRange#IMultiSelection.AddRange}(100, 20);
msel.${AddRange#IMultiSelection.AddRange}(200, 30);
fdoc.FillByteMulti(0x35, msel);
// This method is not available in scripting environment
void FillMulti(ref byte Pattern, uint PatternSize, ${IMultiSelection} Selection, Continue);
HRESULT FillMulti(unsigned char * Pattern, unsigned long PatternSize, ${IMultiSelectionPtr#IMultiSelection} Selection, Continue);
Pattern
PatternSize
Selection
Continue
Fills a given multiple selection with a specified pattern. The pattern is repeated until all given range(s) are filled. bCont parameter specifies whether to continue filling a new range from the previous range, or from the beginning of the pattern.
Complexity: linear-time, depending on the selection's complexity.
Filling a range with a single byte
// fdoc is initialized elsewhere
var msel = fdoc.CreateEmptySelection();
msel.${AddRange#IMultiSelection.AddRange}(100, 20);
msel.${AddRange#IMultiSelection.AddRange}(200, 30);
byte[] pattern = new byte[] { 0x31, 0x32, 0x33 };
fdoc.FillMulti(ref pattern[0], pattern.Length, msel, false);
// This method is not available in scripting environment
void Insert(ref byte Data, ulong Offset, uint InsertSize);
HRESULT Insert(unsigned char * Data, unsigned long long Offset, unsigned long InsertSize);
Data
Offset
InsertSize
Inserts a pattern into the document. Insert command shifts file's data to free up the space to fit an inserted pattern.
Complexity: constant-time.
Inserting a pattern
// fdoc is initialized elsewhere
byte[] pattern = new byte[] { 0x0d, 0x0a };
fdoc.Insert(ref pattern[0], 100, pattern.Length); // insert a given pattern at the offset 100
InsertByte(ByteFill: number, Offset: number, Size: number): void;
void InsertByte(byte ByteFill, ulong Offset, ulong Size);
HRESULT InsertByte(unsigned char ByteFill, unsigned long long Offset, unsigned long long Size);
ByteFill
Offset
Size
Inserts a block of a given size into the document and fill it with a given byte value.
Complexity: constant-time.
Inserting a pattern
// fdoc is initialized elsewhere
fdoc.InsertByte('#', 100, 10000);
// This method is not available in scripting environment
void InsertPattern(ref byte Pattern,
uint PatternSize,
ulong Offset,
ulong Size);
HRESULT InsertPattern(unsigned char * Pattern,
unsigned long PatternSize,
unsigned long long Offset,
unsigned long long Size);
Pattern
PatternSize
Offset
Size
Inserts a given pattern into the document, repeating it to fill the given size. Insert command shifts file's data to free up the space to fit an inserted pattern.
Complexity: constant-time.
Inserting a pattern
// fdoc is initialized elsewhere
byte[] pattern = new byte[] { 0x0d, 0x0a };
fdoc.InsertPattern(ref pattern[0], pattern.Length, 100, 1000);
PutFile(FileName: string, Offset: , InsertMode: boolean): void;
void PutFile(string FileName, ulong Offset, bool InsertMode);
HRESULT PutFile(_bstr_t FileName, unsigned long long Offset, VARIANT_BOOL InsertMode);
FileName
Offset
InsertMode
true
to insert a file's contents, false
to overwrite the current document's data with data from the file.Writes or inserts the contents of the file into the current document. InsertMode
parameter governs the behavior of the function.
Complexity: constant-time.
Concatenating Files
var fdoc = new ActiveXObject("FileDocument.FileDocument");
fdoc.Open("c:\\temp\\file1.bin");
fdoc.PutFile("c:\\temp\\file2.bin", fdoc.FileSize, false);
fdoc.Save(false);
// This method is not available in scripting environment
void Read(ref byte Data, ulong Offset, uint ReadSize);
HRESULT Read(unsigned char * Data, unsigned long long Offset, unsigned long ReadSize);
Data
Offset
ReadSize
Reads data from a document. If requested data exceeds the current document's size, any excess bytes are filled with zeros.
Complexity: constant-time.
Reading Data
// pFileDocument is initialized elsewhere
unsigned char data[256];
pFileDocument->Read(data, 1000, 256);
// This method is not available in scripting environment
void Write(ref byte Data, ulong Offset, uint WriteSize);
HRESULT Write(unsigned char * Data, unsigned long long Offset, unsigned long WriteSize);
Data
Offset
WriteSize
Writes data to a document. The written data overwrites document's existing data and may also increase the file's size if it overlaps the current file's size. Write always creates a new operation in document's operation history.
Complexity: constant-time.
Writing Data
// pFileDocument is initialized elsewhere
unsigned char data[256];
pFileDocument->Write(data, 1000, 256);
CreatePatch(PatchName: string, Options: ${PatchOptions}, PathToStubFile?: string): void;
void CreatePatch(string PatchName, ${PatchOptions} Options, string PathToStubFile);
HRESULT CreatePatch(_bstr_t PatchName, ${PatchOptions} Options, _variant_t PathToStubFile);
PatchName
Options
PathToStubFile
PatchApply32.exe
or PatchApply64.exe
application, installed with the Hex Editor Neo.Creates a patch file. See the Patch Creation section for more information on patches.
Complexity: linear-time, depending on the number and complexity of operations in document's operation history.
Creating patch
// fdoc is initialized elsewhere
// Perform a modification to the file
fdoc.FillByte(0, 100, 20);
fdoc.CreatePatch(@"c:\patch.hexpatch", FileDocumentLib.PatchOptions.PatchCalculateHash | FileDocumentLib.PatchOptions.PatchSaveFileName, null);
// This method is not available in scripting environment
void LoadHistory(IStream Stream);
HRESULT LoadHistory(IStream * Stream);
Stream
Loads a document's operation history from a file.
Complexity: linear-time, depending on the saved history's complexity.
Purge(Level: ${HistoryPurgeLevel}): void;
void Purge(${HistoryPurgeLevel} Level);
HRESULT Purge(${HistoryPurgeLevel} Level);
Level
Purges a document's operation history. See Purging History section for more information.
Complexity: constant-time for all purge levels except HistoryPurgeAllButCurrent
and linear-time for HistoryPurgeAllButCurrent
.
Purging history
// fdoc is initialized elsewhere
fdoc.FillByte(0x35, 100, 40);
// ...
fdoc.Purge(FileDocumentLib.HistoryPurgeLevel.HistoryPurgeAll); // discard all operations
Redo(Steps?: number): void;
void Redo(uint Steps);
HRESULT Redo(_variant_t Steps);
Steps
Redoes Steps
recently undone operations.
Complexity: constant-time.
// This method is not available in scripting environment
void SaveHistory(IStream Stream);
HRESULT SaveHistory(IStream * Stream);
Stream
Saves the document's operation history to a given stream object.
Complexity: linear-time, depending on the history's complexity.
Undo(Steps?: number): void;
void Undo(uint Steps);
HRESULT Undo(_variant_t Steps);
Steps
Undoes last Steps
operations.
Complexity: constant-time.
Copy(Selection: ${IMultiSelection}, MergeBlocks: boolean): void;
void Copy(${IMultiSelection} Selection, bool MergeBlocks);
HRESULT Copy(${IMultiSelectionPtr#IMultiSelection} Selection, VARIANT_BOOL MergeBlocks);
Selection
MergeBlocks
true
to merge selection blocks, false
to leave them as isCopies the given selection to the Clipboard.
Complexity: linear-time, depending on the selection's complexity.
Placing document's data to the Clipboard
// fdoc is defined and obtained elsewhere
var msel = fdoc.CreateEmptySelection(); // create an empty selection object
msel.AddRange(100, 20); // add a first range to the selection
msel.AddRange(200, 20); // add a second range to the selection
fdoc.Copy(msel, false); // place data to the clipboard
Cut(Selection: ${IMultiSelection}, MergeBlocks: boolean): void;
void Cut(${IMultiSelection} Selection, bool MergeBlocks);
HRESULT Cut(${IMultiSelectionPtr#IMultiSelection} Selection, VARIANT_BOOL MergeBlocks);
Selection
MergeBlocks
true
to merge selection blocks, false
to leave them as isCopies the given selection to the Clipboard and removes it from the document.
Complexity: linear-time, depending on the selection's complexity.
Cutting document's data to the Clipboard
// fdoc is defined and obtained elsewhere
var msel = fdoc.CreateEmptySelection(); // create an empty selection object
msel.AddRange(100, 20); // add a first range to the selection
msel.AddRange(200, 20); // add a second range to the selection
fdoc.Cut(msel, false); // place data to the clipboard
Paste(Offset: number, InsertMode: boolean): void;
void Paste(ulong Offset, bool InsertMode);
HRESULT Paste(unsigned long long Offset, VARIANT_BOOL InsertMode);
Offset
InsertMode
true
to insert data, false
to overwrite data.Pastes data from the Clipboard to the given position. Pasted data either overwrites the current document's data, or is inserted into the document, shifting existing data forward, depending on the InsertMode
parameter.
This method is superseded by IFileDocument.Paste2 method, but is still supported.
Using Paste
var fdoc = new FileDocumentLib.FileDocument();
var msel = fdoc.CreateEmptySelection();
msel.AddRange(0, 10);
fdoc.Copy(msel, false);
fdoc.Paste(20, true); // Equivalent to fdoc.Paste2(20, TypeHexByte, true);
fdoc.Paste(100, false); // Equivalent to fdoc.Paste2(100, TypeHexByte, false);
Paste2(Offset: number, Type: ${TextType}, InsertMode: boolean): void;
void Paste2(ulong Offset, ${TextType} Type, bool InsertMode);
HRESULT Paste2(unsigned long long Offset, ${TextType} Type, VARIANT_BOOL InsertMode);
Offset
Type
0x
prefix which forces it to be in base 16.InsertMode
true
to insert data, false
to overwrite data.Pastes data from the Clipboard to the given position. Pasted data either overwrites the current document's data, or is inserted into the document, shifting existing data forward, depending on the InsertMode
parameter.
Using Paste
var fdoc = new FileDocumentLib.FileDocument();
var msel = fdoc.CreateEmptySelection();
msel.AddRange(0, 10);
fdoc.Copy(msel, false);
fdoc.Paste2(20, TextType.TypeHexByte, true);
fdoc.Paste2(100, TextType.TypeHexByte, false);
Paste3(Offset: number, Type: ${TextType}, Flags: ${Paste3Flags}): void;
void Paste3(ulong Offset, ${TextType} Type, ${Paste3Flags} Flags);
HRESULT Paste3(unsigned long long Offset, ${TextType} Type, ${Paste3Flags} Flags);
Offset
Type
0x
prefix which forces it to be in base 16.Flags
Pastes data from the Clipboard to the given position. Pasted data either overwrites the current document's data, or is inserted into the document, shifting existing data forward, depending on the InsertMode
flag in Flags
parameter.
PasteText(Offset: number, Unicode: boolean, InsertMode: boolean): void;
void PasteText(ulong Offset, bool Unicode, bool InsertMode);
HRESULT PasteText(unsigned long long Offset, VARIANT_BOOL Unicode, VARIANT_BOOL InsertMode);
Offset
Unicode
true
) or ANSI (false
).InsertMode
true
to insert data, false
to overwrite data.Pastes text from the Clipboard to the given position. Pasted data either overwrites the current document's data, or is inserted into the document, shifting existing data forward, depending on the InsertMode
parameter.
Unicode parameter tells the Hex Editor Neo to interpret the text in the Clipboard as UNICODE or ANSI. If Unicode
is true
, each character occupies two bytes, otherwise, it occupies a single byte.
PasteText2(Offset: number, CodePage: number, InsertMode: boolean): void;
void PasteText2(ulong Offset, uint CodePage, bool InsertMode);
HRESULT PasteText2(unsigned long long Offset, unsigned long CodePage, VARIANT_BOOL InsertMode);
Offset
CodePage
CP_UNICODE
(hardcoded as -5) to specify UTF-16 encoding.InsertMode
Pastes text from the Clipboard to the given position. Pasted data either overwrites the current document's data, or is inserted into the document, shifting existing data forward, depending on the InsertMode
parameter.
Hex Editor Neo uses the CodePage
to convert the text in the Clipboard. Pass the CP_UNICODE
(hardcoded as -5) to specify the UTF-16 encoding.
This method requires the CF_UNICODETEXT
format to be present in the Clipboard in order to convert to the given encoding. If only CF_TEXT
is available, than it operates exactly like the IFileDocument.PasteText method.
// This method is not available in scripting environment
ulong Find(ref byte DataToFind,
uint DataSize,
${IMultiSelection} Selection,
ulong StartFrom,
bool SearchUp,
bool ignore_case);
unsigned long long Find(unsigned char * DataToFind,
unsigned long DataSize,
${IMultiSelectionPtr#IMultiSelection} Selection,
unsigned long long StartFrom,
VARIANT_BOOL SearchUp,
VARIANT_BOOL ignore_case);
DataToFind
DataSize
Selection
StartFrom
SearchUp
true
to search backwards and false
to search forward.ignore_case
true
to ignore case and false
to perform exact matching.Offset of the located pattern or -1 if pattern was not found.
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
parameter 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.
Searching for a pattern
var fdoc = new FileDocumentLib.FileDocument();
var msec = fdoc.CreateEmptySelection();
fdoc.Open(@"c:\temp\file.txt");
msec.AddRange(0, fdoc.FileSize); // We'll be searching in a whole file
byte[] pattern = new byte[] { 0x0d, 0x0a }; // EOL pattern
ulong EOL_Offset = fdoc.Find(ref pattern[0], pattern.Length, msel, 0, false, false);
// ...
// continue searching
EOL_Offset = fdoc.Find(ref pattern[0], pattern.Length, msel, EOL_Offset + 1, false, false);
// This method is not available in scripting environment
void FindRegExp(string RegExp,
uint SubExpression,
${RegExpFlags} Flags,
ulong StartFrom,
ulong Size,
ref ulong FoundOffset,
ref ulong MatchSize);
HRESULT FindRegExp(_bstr_t RegExp,
unsigned long SubExpression,
${RegExpFlags} Flags,
unsigned long long StartFrom,
unsigned long long Size,
unsigned long long * FoundOffset,
unsigned long long * MatchSize);
RegExp
SubExpression
Flags
StartFrom
Size
FoundOffset
MatchSize
Searches for an occurrence of a regular expression within a given range. To continue searching, call this method again, adjusting StartFrom
field appropriately. If a pattern is not found in the specified range, this method returns an error.
Complexity: depends on the range's size and regular expression complexity.
If regular expression syntax is invalid, the method returns (or throws) an error E_INVALIDARG
. A IFileDocument.RegExpSyntaxError property contains the description of the syntax error.
When match is not found, the method returns (or throws) a NOT_FOUND
error.
This function is obsolete. Use the IFileDocument.FindRegExp2 instead.
// This method is not available in scripting environment
void FindRegExp2(string RegExp,
uint CodePage,
uint SubExpression,
${RegExpFlags} Flags,
ulong StartFrom,
ulong Size,
ref ulong FoundOffset,
ref ulong MatchSize);
HRESULT FindRegExp2(_bstr_t RegExp,
unsigned long CodePage,
unsigned long SubExpression,
${RegExpFlags} Flags,
unsigned long long StartFrom,
unsigned long long Size,
unsigned long long * FoundOffset,
unsigned long long * MatchSize);
RegExp
CodePage
SubExpression
Flags
StartFrom
RegExpTypeUNICODE
flag is specified.Size
RegExpTypeUNICODE
flag is specified.FoundOffset
MatchSize
Searches for an occurrence of a regular expression within a given range. To continue searching, call this method again, adjusting StartFrom
field appropriately. If a pattern is not found in the specified range, this method returns an error.
Complexity: depends on the range's size and regular expression complexity.
If regular expression syntax is invalid, the method returns (or throws) an error E_INVALIDARG
. A IFileDocument.RegExpSyntaxError property contains the description of the syntax error.
When match is not found, the method returns (or throws) a NOT_FOUND
error.
// This method is not available in scripting environment
void FindAll(ref byte DataToFind,
uint DataSize,
${IMultiSelection} Selection,
bool IgnoreCase,
${IMultiSelection} Found);
HRESULT FindAll(unsigned char * DataToFind,
unsigned long DataSize,
${IMultiSelectionPtr#IMultiSelection} Selection,
VARIANT_BOOL IgnoreCase,
${IMultiSelectionPtr#IMultiSelection} Found);
DataToFind
DataSize
Selection
IgnoreCase
true
to ignore case, false
to perform exact matching.Found
Locates all occurrences of a given pattern within a given multiple selection. You provide the function with an output Multiple Selection Object Found
, in which it stores all located ranges. This object is automatically cleared before the operation begins. When the method returns, check the IMultiSelection.Empty property to see if there were any pattern occurrences.
Complexity: linear-time, depending on the file's size and selection's complexity.
Searching all pattern occurrences
var fdoc = new FileDocumentLib.FileDocument();
var msel = fdoc.CreateEmptySelection();
var mselOutput = fdoc.CreateEmptySelection();
fdoc.Open(@"c:\temp\file.txt");
msel.AddRange(0, fdoc.FileSize); // We'll be searching in a whole file
byte[] pattern = new byte[] { 0x0d, 0x0a }; // EOL pattern
fdoc.FindAll(ref pattern[0], pattern.Length, msel, false, mselOutput);
if (!mselOutput.Empty) // check if there are any matches
fdoc.Copy(mselOutput,false); // copy them to the Clipboard
FindAllRegExp(RegExp: string,
SubExpression: number,
Flags: ${RegExpFlags},
StartFrom: number,
Size: number,
Found: ${IMultiSelection}): void;
void FindAllRegExp(string RegExp,
uint SubExpression,
${RegExpFlags} Flags,
ulong StartFrom,
ulong Size,
${IMultiSelection} Found);
HRESULT FindAllRegExp(_bstr_t RegExp,
unsigned long SubExpression,
${RegExpFlags} Flags,
unsigned long long StartFrom,
unsigned long long Size,
${IMultiSelectionPtr#IMultiSelection} Found);
RegExp
SubExpression
Flags
StartFrom
RegExpTypeUNICODE
flag is specified.Size
RegExpTypeUNICODE
flag is specified.Found
A number of occurrences
Locates all matches of a given regular expression in a given range. You provide the function with an output Multiple Selection Object Found
, in which it stores all located ranges. This object is automatically cleared before the operation begins. When the method returns, check the IMultiSelection.Empty property to see if there were any pattern occurrences.
Complexity: depends on the range's size and regular expression complexity.
This method is obsolete. Use the IFileDocument.FindAllRegExp2 instead.
FindAllRegExp2(RegExp: string,
CodePage: number,
SubExpression: number,
Flags: ${RegExpFlags},
StartFrom: number,
Size: number,
Found: ${IMultiSelection}): void;
void FindAllRegExp2(string RegExp,
uint CodePage,
uint SubExpression,
${RegExpFlags} Flags,
ulong StartFrom,
ulong Size,
${IMultiSelection} Found);
HRESULT FindAllRegExp2(_bstr_t RegExp,
unsigned long CodePage,
unsigned long SubExpression,
${RegExpFlags} Flags,
unsigned long long StartFrom,
unsigned long long Size,
${IMultiSelectionPtr#IMultiSelection} Found);
RegExp
CodePage
SubExpression
Flags
StartFrom
RegExpTypeUNICODE
flag is specified.Size
RegExpTypeUNICODE
flag is specified.Found
A number of occurrences.
Locates all matches of a given regular expression in a given range. You provide the function with an output Multiple Selection Object Found
, in which it stores all located ranges. This object is automatically cleared before the operation begins. When the method returns, check the IMultiSelection.Empty property to see if there were any pattern occurrences.
Complexity: depends on the range's size and regular expression complexity.
// This method is not available in scripting environment
void Replace(ulong Offset,
uint SizeFrom,
ref byte To,
uint SizeTo);
HRESULT Replace(unsigned long long Offset,
unsigned long SizeFrom,
unsigned char * To,
unsigned long SizeTo);
Offset
SizeFrom
To
SizeTo
Replaces the given block with a pattern. This method replaces a range described by Offset
and SizeFrom
parameters with a pattern.
Complexity: constant-time.
Replacing a pattern
var fdoc = new FileDocumentLib.FileDocument();
var msec = fdoc.CreateEmptySelection();
fdoc.Open(@"c:\temp\file.txt");
msec.AddRange(0, fdoc.FileSize); // We'll be searching in a whole file
byte[] pattern1 = new byte[] { 0x0d, 0x0a }; // EOL pattern
byte[] pattern2 = new byte[] { 0x0d, 0x0a, 0x0d, 0x0a }; // Double-EOL pattern
ulong EOL_Offset = fdoc.Find(ref pattern1[0], pattern1.Length, msel, 0, false, false);
if (EOL_Offset != -1)
fdoc.Replace(EOL_Offset, pattern1.Length, ref pattern2[0], pattern2.Length);
// This method is not available in scripting environment
void ReplaceAll(ref byte From,
uint SizeFrom,
ref byte To,
uint SizeTo,
bool IgnoreCase,
${IMultiSelection} Selection);
HRESULT ReplaceAll(unsigned char * From,
unsigned long SizeFrom,
unsigned char * To,
unsigned long SizeTo,
VARIANT_BOOL IgnoreCase,
${IMultiSelectionPtr#IMultiSelection} Selection);
From
SizeFrom
To
SizeTo
IgnoreCase
true
to ignore case, false
to perform exact matching.Selection
A number of replacements done.
Finds and replaces all occurrences of the given pattern with another pattern.
Complexity: varying.
Searching all pattern occurrences
var fdoc = new FileDocumentLib.FileDocument();
var msel = fdoc.CreateEmptySelection();
fdoc.Open(@"c:\temp\file.txt");
msel.AddRange(0, fdoc.FileSize); // We'll be searching in a whole file
byte[] pattern1 = new byte[] { 0x0d, 0x0a }; // EOL pattern
byte[] pattern2 = new byte[] { 0x0d, 0x0a, 0x0d, 0x0a }; // Double-EOL pattern
ulong nReplacements = fdoc.ReplaceAll(ref pattern1[0], pattern1.Length, ref pattern2[0], pattern2.Length, false, msel);
// This method is not available in scripting environment
void ReplaceAllRegExp(string RegExp,
uint SubExpression,
${RegExpFlags} Flags,
ref byte To,
uint SizeTo,
ulong StartFrom,
ulong Size);
HRESULT ReplaceAllRegExp(_bstr_t RegExp,
unsigned long SubExpression,
${RegExpFlags} Flags,
unsigned char To,
unsigned long SizeTo,
unsigned long long StartFrom,
unsigned long long Size);
RegExp
SubExpression
Flags
To
SizeTo
StartFrom
RegExpFlags.RegExpTypeUNICODE
flag is specified.Size
RegExpFlags.RegExpTypeUNICODE
flag is specified.A number of occurrences.
Finds and replaces all occurrences of regular expression matches with a given pattern.
Complexity: varying.
This method is obsolete. Use the IFileDocument.ReplaceAllRegExp2 instead.
// This method is not available in scripting environment
void ReplaceAllRegExp2(string RegExp,
uint CodePage,
uint SubExpression,
${RegExpFlags} Flags,
ref byte To,
uint SizeTo,
ulong StartFrom,
ulong Size);
HRESULT ReplaceAllRegExp2(_bstr_t RegExp,
unsigned long CodePage,
unsigned long SubExpression,
${RegExpFlags} Flags,
unsigned char * To,
unsigned long SizeTo,
unsigned long long StartFrom,
unsigned long long Size);
RegExp
CodePage
CP_UNICODE
(-5) for UTF-16.SubExpression
Flags
To
SizeTo
StartFrom
RegExpFlags.RegExpTypeUNICODE
flag is specified.Size
RegExpFlags.RegExpTypeUNICODE
flag is specified.A number of occurrences.
Finds and replaces all occurrences of regular expression matches with a given pattern.
Complexity: varying.
ReplaceAllRegExpWithRegExp(RegExp: string,
ReplacePattern: string,
CodePage: number,
Flags: ${RegExpFlags},
StartFrom: number,
Size: number): void;
void ReplaceAllRegExpWithRegExp(string RegExp,
string ReplacePattern,
uint CodePage,
${RegExpFlags} Flags,
ulong StartFrom,
ulong Size);
HRESULT ReplaceAllRegExpWithRegExp(_bstr_t RegExp,
_bstr_t ReplacePattern,
unsigned long CodePage,
${RegExpFlags} Flags,
unsigned long long StartFrom,
unsigned long long Size);
RegExp
ReplacePattern
CodePage
CP_UNICODE
(-5) for UTF-16.Flags
StartFrom
Size
A number of occurrences.
Finds and replaces all occurrences of regular expression matches with a given regular expression pattern.
Complexity: varying.
Gap(pSelection: ${IMultiSelection}): void;
void Gap(${IMultiSelection} pSelection);
void Gap(${IMultiSelection} pSelection);
pSelection
“Gaps” specified regions, that is, marks them as “absent”. Currently persisted only in encoded binary formats, like Intel HEX or Motorola S-records.
ArithmeticOp(Selection: ${IMultiSelection},
Type: ${ArithmeticOpType},
OpSize: ${OperandSizeType},
Operand?: any): void;
void ArithmeticOp(${IMultiSelection} Selection,
${ArithmeticOpType} Type,
${OperandSizeType} OpSize,
object Operand);
HRESULT ArithmeticOp(${IMultiSelectionPtr#IMultiSelection} Selection,
${ArithmeticOpType} Type,
${OperandSizeType} OpSize,
_variant_t Operand);
Selection
Type
OpSize
Operand
ArithmeticOpNegation
operation type.Performs an arithmetic operation on a given selection.
Complexity: linear-time, depending on selection's complexity.
// This method is not available in scripting environment
void BitwiseOp(${IMultiSelection} Selection, ${BitwiseOpType} Type, ref byte Data, uint DataSize);
HRESULT BitwiseOp(${IMultiSelectionPtr#IMultiSelection} Selection, ${BitwiseOpType} Type, unsigned char * Data, unsigned long DataSize);
Selection
Type
Data
DataSize
BitwiseOpNOT
operation type.Performs a bitwise operation on a given selection.
Complexity: linear-time, depending on selection's complexity.
CaseOp(Selection: ${IMultiSelection},
Type: ${CaseOpType},
Unicode: boolean,
CodePage?: number): void;
void CaseOp(${IMultiSelection} Selection,
${CaseOpType} Type,
bool Unicode,
object CodePage);
HRESULT CaseOp(${IMultiSelectionPtr#IMultiSelection} Selection,
${CaseOpType} Type,
VARIANT_BOOL Unicode,
_variant_t CodePage);
Selection
Type
Unicode
true
to treat selection data as UNICODE, false
otherwise. If this parameter is true
, all blocks in a given selection must have alignment of 2 bytes.CodePage
Unicode
parameter is True.Performs a case change operation on a given selection.
Complexity: linear-time, depending on selection's complexity.
ShiftOp(Selection: ${IMultiSelection}, Type: ${ShiftOpType}, OpSize: , Bits: number): void;
void ShiftOp(${IMultiSelection} Selection, ${ShiftOpType} Type, OpSize, uint Bits);
HRESULT ShiftOp(${IMultiSelectionPtr#IMultiSelection} Selection, ${ShiftOpType} Type, OpSize, unsigned long Bits);
Selection
Type
OpSize
Bits
Performs a shift operation on a given selection.
Complexity: linear-time, depending on selection's complexity.
ReverseOp(Selection: ${IMultiSelection}, Type: ${ReverseOpType}, OpSize: ${OperandSizeType}): void;
void ReverseOp(${IMultiSelection} Selection, ${ReverseOpType} Type, ${OperandSizeType} OpSize);
HRESULT ReverseOp(${IMultiSelectionPtr#IMultiSelection} Selection, ${ReverseOpType} Type, ${OperandSizeType} OpSize);
Selection
Type
OpSize
Performs a bit or byte reverse operation on a given selection.
Complexity: linear-time, depending on selection's complexity.
// This method is not available in scripting environment
ulong[] GatherStatistics(${IMultiSelection} Selection);
unsigned long long[256] GatherStatistics(${IMultiSelectionPtr#IMultiSelection} Selection);
Selection
Statistics array.
Calculates file statistics. See the General Statistics section for more information. On method return, each of 256 elements in an array contains the number of corresponding byte occurrences.
Complexity: linear-time, depending on the file's size.
Calculating General Statistics
// pFileDocument and pMultiSelection are initialized elsewhere
unsigned long long data[256];
pFileDocument->GatherStatistics(pMultiSelection, data);
// This method is not available in scripting environment
void PatternStatistics(ref byte Pattern,
uint DataSize,
bool IgnoreCase,
ref ulong DataBuffer,
uint Blocks,
${IMultiSelection} Selection);
HRESULT PatternStatistics(unsigned char * Pattern,
unsigned long DataSize,
VARIANT_BOOL IgnoreCase,
unsigned long long * DataBuffer,
unsigned long Blocks,
${IMultiSelectionPtr#IMultiSelection} Selection);
Pattern
DataSize
IgnoreCase
true
to ignore case, false
to perform exact matching.DataBuffer
Blocks
Selection
Calculates file statistics. See the Pattern Statistics section for more information. On method return, the DataBuffer
buffer is filled with calculated statistics values.
Complexity: linear-time, depending on the file's size.
Calculating Pattern Statistics
// pFileDocument and pMultiSelection are initialized elsewhere
unsigned __int64 data[1024];
unsigned char pattern[] = { 0x0d, 0x0a };
pFileDocument->PatternStatistics(pattern, sizeof(pattern), false, data, 1024, pMultiSelection);
// This method is not available in scripting environment
void PatternStatisticsRegExp(string RegExp,
uint SubExpression,
${RegExpFlags} Flags,
ref ulong DataBuffer,
uint Blocks,
ulong StartFrom,
ulong Size);
HRESULT PatternStatisticsRegExp(_bstr_t RegExp,
unsigned long SubExpression,
${RegExpFlags} Flags,
unsigned long long * DataBuffer,
unsigned long Blocks,
unsigned long long StartFrom,
unsigned long long Size);
RegExp
SubExpression
Flags
DataBuffer
Blocks
StartFrom
RegExpFlags.RegExpTypeUNICODE
flag is specified.Size
RegExpFlags.RegExpTypeUNICODE
flag is specified.Calculates file statistics for a given regular expression. See the Pattern Statistics section for more information. On method return, the DataBuffer
buffer is filled with calculated statistics values.
Complexity: linear-time, depending on the file's size and regular expression complexity.
This method is obsolete. Use the IFileDocument.PatternStatisticsRegExp2 instead.
// This method is not available in scripting environment
void PatternStatisticsRegExp2(string RegExp,
uint CodePage,
uint SubExpression,
${RegExpFlags} Flags,
ref ulong DataBuffer,
uint Blocks,
ulong StartFrom,
ulong Size);
HRESULT PatternStatisticsRegExp2(_bstr_t RegExp,
unsigned long CodePage,
unsigned long SubExpression,
${RegExpFlags} Flags,
unsigned long long * DataBuffer,
unsigned long Blocks,
unsigned long long StartFrom,
unsigned long long Size);
RegExp
CodePage
CP_UNICODE
(-5) for UTF-16.SubExpression
Flags
DataBuffer
Blocks
StartFrom
RegExpFlags.RegExpTypeUNICODE
flag is specified.Size
RegExpFlags.RegExpTypeUNICODE
flag is specified.Calculates file statistics for a given regular expression. See the Pattern Statistics section for more information. On method return, the DataBuffer
buffer is filled with calculated statistics values.
Complexity: linear-time, depending on the file's size and regular expression complexity.
CreateEmptySelection(): ${IMultiSelection};
${IMultiSelection} CreateEmptySelection();
${IMultiSelectionPtr#IMultiSelection} CreateEmptySelection();
Returns the newly created Multiple Selection Object.
Sel Pointer to a variable that receives a pointer to the IMultiSelection interface of created multiple selection object.
Creates an empty selection object. Complexity: constant-time.
Creating an empty selection object
// pFileDocument is obtained elsewhere
IMultiSelection *pMultiSelection {};
if (SUCCEEDED(pFileDocument->CreateEmptySelection(&pMultiSelection)))
{
// work with a selection
pMultiSelection->Release(); // release object
}
CreateSequence(): ${ISequence};
${ISequence} CreateSequence();
${ISequencePtr#ISequence} CreateSequence();
Create an empty Sequence Object.
BitwiseOpS(Selection: ${IMultiSelection}, Type: ${BitwiseOpType}, Sequence: ${ISequence}): void;
// This method is not available in managed environment
// This method is not available in native environment
Selection
Type
Sequence
Performs a bitwise operation on a given selection.
Complexity: linear-time, depending on selection's complexity.
This method is a replacement for IFileDocument.BitwiseOp when used in scripting languages.
FillMultiS(Sequence: ${ISequence}, Selection: ${IMultiSelection}, Continue: boolean): void;
// This method is not available in managed environment
// This method is not available in native environment
Sequence
Selection
Continue
Fills a given multiple selection with a specified pattern. The pattern is repeated until all given range(s) are filled. Continue
parameter specifies whether to continue filling a new range from the previous range, or from the beginning of the pattern.
Complexity: linear-time, depending on the selection's complexity.
This method is a replacement for IFileDocument.FillMulti when used in scripting languages.
Filling a range with a single byte
// fdoc is initialized elsewhere
var msel = fdoc.CreateEmptySelection();
msel.AddRange(100, 20);
msel.AddRange(200, 30);
var pattern = fdoc.CreateSequence();
pattern.AddData(HexBytes, 0x31, 0x32, 0x33);
fdoc.FillMultiS(pattern, msel, false);
FillS(Sequence: ${ISequence}, Offset: number, Size: number): void;
// This method is not available in managed environment
// This method is not available in native environment
Sequence
Offset
Size
Fills a given range with a given pattern. A pattern is repeated until the required number of bytes is written to the file. If file is shorter than the filling range, the file's size is increased.
Complexity: constant-time.
This method is a replacement for IFileDocument.Fill when used in scripting languages.
Filling a range with a simple pattern
// fdoc is initialized elsewhere
var pattern = fdoc.CreateSequence();
pattern.AddText("Simple Pattern", false);
fdoc.FillS(pattern, 0x10000, 0x10ff);
FindAllS(Sequence: ${ISequence},
Selection: ${IMultiSelection},
IgnoreCase: boolean,
Found: ${IMultiSelection}): void;
// This method is not available in managed environment
// This method is not available in native environment
Sequence
Selection
IgnoreCase
Found
Locates all occurrences of a given pattern within a given multiple selection. You provide the function with an output Multiple Selection Object Found
, in which it stores all located ranges. This object is automatically cleared before the operation begins. When the method returns, check the IMultiSelection.Empty property to see if there were any pattern occurrences.
Complexity: linear-time, depending on the file's size and selection's complexity.
This method is a replacement for IFileDocument.FindAll when used in scripting languages.
Searching all pattern occurrences
var fdoc = new ActiveXObject("FileDocument.FileDocument");
var msel = fdoc.CreateEmptySelection();
var mselOutput = fdoc.CreateEmptySelection();
fdoc.Open("c:\\temp\\file.txt");
msel.AddRange(0, fdoc.FileSize); // We'll be searching in a whole file
var pattern = fdoc.CreateSequence();
pattern.AddData(HexBytes, 0x0d, 0x0a); // EOL pattern
fdoc.FindAllS(pattern, msel, false, mselOutput);
if (!mselOutput.Empty) // check if there are any matches
fdoc.Copy(mselOutput,false); // copy them to the Clipboard
FindS(Sequence: ${ISequence},
Selection: ${IMultiSelection},
StartFrom: number,
SearchUp: boolean,
IgnoreCase: boolean): void;
// This method is not available in managed environment
// This method is not available in native environment
Sequence
Selection
StartFrom
SearchUp
true
to search backwards and false
to search forward.IgnoreCase
true
to ignore case and false
to perform exact matching.Offset of the located pattern or -1 if pattern was not found.
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.
Searching for a pattern
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));
InsertPatternS(Sequence: ${ISequence}, Offset: number, Size: number): void;
// This method is not available in managed environment
// This method is not available in native environment
Sequence
Offset
Size
Inserts a given pattern into the document, repeating it to fill the given size. Insert command shifts file's data to free up the space to fit an inserted pattern.
Complexity: constant-time.
This method is a replacement for IFileDocument.InsertPattern when used in scripting languages.
Inserting a pattern
// fdoc is initialized elsewhere
var pattern = fdoc.CreateSequence();
pattern.AddData(HexBytes, 0x0d, 0x0a);
fdoc.InsertPatternS(pattern, 100, 1000);
InsertS(Sequence: ${ISequence}, Offset: number): void;
// This method is not available in managed environment
// This method is not available in native environment
Sequence
Offset
Inserts a pattern into the document. Insert command shifts file's data to free up the space to fit an inserted pattern.
Complexity: constant-time.
This method is a replacement for IFileDocument.Insert when used in scripting languages.
Inserting a pattern
// fdoc is initialized elsewhere
var pattern = fdoc.CreateSequence();
pattern.AddData(HexBytes, 0x0d, 0x0a);
fdoc.InsertS(pattern, 100); // insert a given pattern at the offset 100
ReadS(Sequence: ${ISequence}, Offset: number): void;
// This method is not available in managed environment
// This method is not available in native environment
Sequence
Offset
Reads data from a document. If requested data exceeds the current document's size, any excess bytes are filled with zeros.
Complexity: constant-time.
This method is a replacement for IFileDocument.Read when used in scripting languages.
Reading Data
// fdoc is initialized elsewhere
var seq = fdoc.CreateSequence();
fdoc.Length = 256;
fdoc.ReadS(seq, 1000);
ReplaceAllRegExpS(RegExp: string,
SubExpression: number,
Flags: ${RegExpFlags},
Sequence: ${ISequence},
StartFrom: number,
Size: number): void;
// This method is not available in managed environment
// This method is not available in native environment
RegExp
SubExpression
Flags
Sequence
StartFrom
RegExpFlags.RegExpTypeUNICODE
flag is specified.Size
RegExpFlags.RegExpTypeUNICODE
flag is specified.A number of occurrences.
Finds and replaces all occurrences of regular expression matches with a given pattern.
Complexity: varying.
This method is a replacement for IFileDocument.ReplaceAllRegExp when used in scripting languages. This method is obsolete. Use the IFileDocument.ReplaceAllRegExp2S instead.
ReplaceAllRegExp2S(RegExp: string,
CodePage: number,
SubExpression: number,
Flags: ${RegExpFlags},
Sequence: ${ISequence},
StartFrom: number,
Size: number): void;
// This method is not available in managed environment
// This method is not available in native environment
RegExp
CodePage
SubExpression
Flags
Sequence
StartFrom
RegExpFlags.RegExpTypeUNICODE
flag is specified.Size
RegExpFlags.RegExpTypeUNICODE
flag is specified.A number of occurrences.
Finds and replaces all occurrences of regular expression matches with a given pattern.
Complexity: varying.
This method is a replacement for IFileDocument.ReplaceAllRegExp2 when used in scripting languages.
ReplaceAllS(SequenceFrom: ${ISequence},
SequenceTo: ${ISequence},
IgnoreCase: boolean,
Selection: ${IMultiSelection}): void;
// This method is not available in managed environment
// This method is not available in native environment
SequenceFrom
SequenceTo
IgnoreCase
true
to ignore case, false
to perform exact matching.Selection
A number of replacements done.
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.
Searching all pattern occurrences
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);
ReplaceS(Offset: number, Size: number, Sequence: ${ISequence}): void;
// This method is not available in managed environment
// This method is not available in native environment
Offset
Size
Sequence
Replaces the given block with a pattern. This method replaces a range described by Offset
and Size
parameters with a pattern.
Complexity: constant-time.
This method is a replacement for IFileDocument.Replace when used in scripting languages.
Replacing a pattern
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 pattern1 = fdoc.CreateSequence();
var pattern2 = fdoc.CreateSequence();
pattern1.AddData(HexBytes,0x0d,0x0a); // EOL pattern
pattern2.AddDate(HexBytes,0x0d,0x0a,0x0d,0x0a); // Double-EOL pattern
var EOL_Offset = fdoc.ToNumber(fdoc.FindS(pattern1, msel, 0, false, false));
if (EOL_Offset != -1)
fdoc.ReplaceS(EOL_Offset, pattern1.Length, pattern2);
ToNumber(Value: any): number;
// This method is not available in managed environment
// This method is not available in native environment
Value
Value, converted to decimal type.
Converts 64-bit integer into scripting compatible integer. Hex Editor Neo extensively uses 64-bit integer numbers. Scripting languages do not directly support such values, so this method may be used to convert them to supported decimal type.
Value conversion
// document1 and document2 are defined elsewhere
document1.FileSize = document2.FileSize; // valid, no processing in Javascript.
// Passing 64-bit integers is supported
document1.FileSize = document2.FileSize / 2; // invalid, "Not a Number" exception is thrown
document1.FileSize = document2.ToNumber(document2.FileSize) / 2; // valid
WriteS(Sequence: ${ISequence}, Offset: number): void;
// This method is not available in managed environment
// This method is not available in native environment
Sequence
Offset
Writes data to a document. The written data overwrites document's existing data and may also increase the file's size if it overlaps the current file's size. Write always creates a new operation in document's operation history.
Complexity: constant-time.
This method is a replacement for IFileDocument.Write when used in scripting languages.
Writing Data
// fdoc is initialized elsewhere
var seq = fdoc.CreateSequence();
fdoc.AddData(HexBytes, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
fdoc.WriteS(seq, 1000);