About Buffer Constructors
This topic describes the formats you can use to create a buffer object.
The following table describes the buffer constructor arguments that are common to formats A, B, C, and D.
Argument | Description |
---|---|
unicode |
You can use one of the following values:
|
bigEndian |
You can use one of the following values:
|
Format A
new Buffer([size] [, unicode] [, bigEndian]);
The following table describes the buffer constructor arguments that are specific to format A.
Argument | Description |
---|---|
size |
The size of the new buffer that Siebel eScript creates. You can do one of the following:
|
Format B
new Buffer( string [, unicode] [, bigEndian] );
Format B creates a new buffer object from a string that you provide. A line of code that uses format B creates a new buffer object from the buffer provided. Siebel CRM copies the contents of the buffer into the new buffer object. The unicode argument and the bigEndian argument do not affect this conversion, although they do set the relevant flags for future use.
The following table describes the buffer constructor arguments that are specific to format B.
Argument | Description |
---|---|
string |
The string that Siebel eScript uses as input to create the buffer. If the string argument contains a Unicode string, then Siebel eScript creates the buffer as a Unicode string. To use a Unicode string, you must enable Unicode in the Siebel application. To override this behavior, you can specify false in the optional unicode argument. The size of the buffer depends on if the string is a Unicode string:
A buffer constructor does not add a terminating null byte at the end of the string. |
Format C
new Buffer(buffer [, unicode] [, bigEndian]);
The following table describes the buffer constructor arguments that are specific to format C.
Argument | Description |
---|---|
buffer |
The buffer that Siebel eScript uses as input to create the new buffer. |
Format D
new Buffer(bufferobject);
A line of code that uses format D creates a new buffer object from another buffer object. Siebel CRM copies the contents of the buffer object to the new buffer verbatim, including the cursor position, size, and data.
The following table describes the buffer constructor arguments that are specific to format D.
Argument | Description |
---|---|
bufferobject |
The buffer object that Siebel eScript uses as input to create the new buffer. |
Example
The following example creates new buffer objects:
function BufferConstruct()
{
TheApplication().TraceOn("c:\\temp\\BufferTrace.doc","Allocation","All");
// Create empty buffer with size 100
var buff1 = new Buffer(100 , true , true);
// Create a buffer from string
var buff2 = new Buffer("This is a buffer String constructor example", true);
// Create buffer from buffer
var buff3 = new Buffer(buff2,false);
try
{
with(buff1)
{
// Add values from 0-99 to the buffer
for(var i=0;i<size;i++)
{
putValue(i);
}
var val = "";
cursor=0;
// Read the buffer values into variable
for(var i=0;i<size;i++)
{
val += getValue(1)+" ";
}
// Trace the buffer value
TheApplication().Trace("Buffer 1 value: "+val);
}
with(buff2)
{
// Trace buffer 2
TheApplication().Trace("Buffer 2 value: "+getString());
}
// Trace buffer 3
with(buff3)
{
TheApplication().Trace("Buffer 3 value: "+getString());
}
}
catch(e)
{
TheApplication().Trace(e.toString());
}
}