Prototype for BinaryDocument.Content objects
You cannot create these objects, you can only get access to them inside an BinaryDocument.
var doc = current_frame.coordinator.document;
// with an activate binary view
var left_content = doc.content.left;
none.
none.
ECMerge 2.4
BinaryDocument.Content let you access the content of a particular pane.
Property | Description |
length | Integer. length in bytes of this content |
Note that unlike TextDocument.Content, the toString() function is not provided. Binary files of arbitrary size can be handled of ECMerge and toString() needs to return a string fitting in memory.
Obtaining the length of a content.
var doc = current_frame.coordinator.document;
// with an active binary frame
var left_content = doc.content.left;
var sel = new BinaryDocument.Selection (left_content);
alert ("There are "+ sel.end + " bytes in the left
content");
BinaryDocument object.
function get_text (selection)
returns a String.
selection. BinaryDocument.Selection object. Selection from which the text is requested
BinaryDocument.Content object.
ECMerge 2.4
Returns the text covered by the selection.
Retrieves the 100 th first bytes of the right side and logs them:
var doc =
current_frame.coordinator.document; // with an
active binary frame
log (doc.content.left.get_text (LinearRange (0,
100));
BinaryDocument.Content object, BinaryDocument.Selection object
function read_number (offset, size, endianess, type)
returns a Number.
offset. Number. Position in the file (in bytes)
size. Number. Size in bytes of the binary
representation of the number to decode.
endianess. String. Two values are accepted:
'big'
and
'little'
.
type. String. Three values are accepted:
'int'
,
'uint'
,
'ieeefloat'
.
BinaryDocument.Content object.
ECMerge 2.4
Returns the numeric value of the number stored in given binary format. ECMerge can decode the following combinations. All of them are available in little and big endian.
Type string | Size (in bytes) |
ieeefloat | 2, 4, 8 |
uint | Any between 1 and 8 |
int | Any between 1 and 8 |
This method main usage is to read files headers to determine offsets and sizes of ignorable dynamic fields.
Retrieves an unsigned int coded in 4 bytes at offset 10 in little endian format then logs it to screen:
var doc =
current_frame.coordinator.document; // with an
active binary frame
log (doc.content.left.read_number (10, 4, 'little',
'uint'));
BinaryDocument.Content object, BinaryDocument.Selection object