Ellié Computing Home Page
My Shopping Cart

Your shopping cart is empty

Display Cart

Call us at +1 586 62 ELLIE / +1 586 62 35543 Office Closed
sales@elliecomputing.com - Contact us


BinaryDocument.Content object

 

 

Prototype for BinaryDocument.Content objects

Syntax

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;

Parameters

 none.

Property Of

none.

Implemented In

ECMerge 2.4

Description

BinaryDocument.Content let you access the content of a particular pane.

Properties

Property Description
length Integer. length in bytes of this content

 

Methods

get_text
read_number

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.

Examples

Example 1.

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");

See Also 

BinaryDocument object.

 

Method get_text

Syntax

function get_text (selection)
returns a String.

Parameters

selection. BinaryDocument.Selection object. Selection from which the text is requested

Method Of

BinaryDocument.Content object.

Implemented In

ECMerge 2.4

Description

Returns the text covered by the selection.

Examples

Example 1.

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));

See Also 

  BinaryDocument.Content object, BinaryDocument.Selection object

 

Method read_number

Syntax

function read_number (offset, size, endianess, type)
returns a Number.

Parameters

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'.

Method Of

BinaryDocument.Content object.

Implemented In

ECMerge 2.4

Description

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.

Examples

Example 1.

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'));

See Also 

  BinaryDocument.Content object, BinaryDocument.Selection object