|
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 | sourceObj | binary | | Required. An instance of a Binary object from which the slice is to be taken. | start | number | | Required. Offset within the source object from which the slice is to start. | length | number | | 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;
}
}
|
|
(loadtime : 18ms) |