Whitebeam Object Definition

Site Map
 
Home
 
Application Guide
Reference
  Installation
  Configuration
  XML Markup
  JavaScript Classes
  ROM
  Templates
  Environment
  Dev Process
  Tools
  External Links
  Example libraries
Community
Contact Whitebeam
To-Do
Download
Credits
Licence
Whitebeam Users
 
 
 

Whitebeam Object Definition

Method Description

Binary.slice()

Take a slice from an existing binary object.

Syntax

binary = Binary.slice(sourceObj, start, length)

Parameters

The 'Binary.slice' method takes 3 parameters:

Name Type/Value Range/Length Description
sourceObjbinary  Required. An instance of a Binary object from which the slice is to be taken.
startnumber  Required. Offset within the source object from which the slice is to start.
lengthnumber  Optional. The length of the slice to take. If this parameter is missing then the slice continues until the end of the binary object.

Results

The 'Binary.slice' method returns binary:

Type/Value Range/Length Description
binary  

Remarks

This method takes a slice from an existing binary object and populates this object with a copy of that slice. The slice function is similar to the 'substr' method on Strings, but takes a copy from one binary object directly into another.

The primary use of this method is to be able to break a big binary object into multiple smaller objects such that they can be saved in, for example, the file template.

See the binary object technical note for details

Example

var maxSliceSize = 100*1024;
var binSlice = new Binary;
var binObj = new Binary;
var sliceArray = [];
 
if (binObj.load('/bigfile.gif')) {
  var offset=0;
  while (offset<binObj.length) {
    binSlice.slice(binObj,offset,maxSliceSize);
    writeBlockToFile(binSlice);
    offset += maxSliceSize;
  }
}
Whitebeam release 1.3.36
(loadtime : 18ms)