contents   index   previous   next



Buffer()

syntax:

new Buffer([size[, unicode[, bigEndian]]])

new Buffer(string[, unicode[, bigEndian]]])

new Buffer(buffer[, unicode[, bigEndian]]])

new Buffer(bufferObject)

where:

size - size of buffer to be created.

 

string - string of characters from which to create a buffer.

 

buffer - buffer of characters from which to create another buffer.

 

bufferObject - buffer to be duplicated.

 

unicode - boolean flag for the initial state of the Buffer unicode property of this buffer.

 

bigEndian - numeric description of the initial state of the Buffer bigEndian property of this buffer.

 

return:

object - the new Buffer object created.

 

description:

To create a Buffer object, use syntax as shown by the following:

 

new Buffer([size[, unicode[, bigEndian]]]);

 

A line of code following this syntax creates a new Buffer object. If size is specified, then the new buffer is created with the specified size, filled with null bytes. If no size is specified, then the buffer is created with a size of 0, though it can be extended dynamically later. The unicode parameter is an optional boolean flag describing the initial state of the .unicode flag of the object. Similarly, bigEndian describes the initial state of the bigEndian parameter of the buffer. If unspecified, these parameters default to the values described below.

 

new Buffer(string[, unicode[, bigEndian]]]);

 

A line of code following this syntax creates a new Buffer object from the string provided. If string is a unicode string (unicode is enabled within the application), then the buffer is created as a unicode string. This behavior can be overridden by specifying true or false with the optional boolean unicode parameter. If this parameter is set to false, then the buffer is created as an ASCII string, regardless of whether or not the original string was in unicode or not. Similarly, specifying true will ensure that the buffer is created as a unicode string. The size of the buffer is the length of the string (twice the length if it is unicode). This constructor does not add a terminating null byte at the end of the string. The bigEndian flag behaves the same way as in the first constructor.

 

new Buffer(buffer[, unicode[, bigEndian]])

 

A line of code following this syntax creates a new Buffer object from the buffer provided. The contents of the buffer are copied as is into the new Buffer object. The unicode and bigEndian parameters do not affect this conversion, though they do set the relevant flags for future use.

 

new Buffer(bufferObject);

 

A line of code following this syntax creates a new Buffer object from another Buffer object. Everything is duplicated exactly from the other bufferObject, including the Buffer cursor location and the Buffer size.

 

All of the Buffer construction calls above may be done without the new constructor starting with ScriptEase 5.00.

 

see:

Blob object

 

 


Buffer getString()