Siebel eScript Language Reference > Methods Reference > Buffer Methods >

About Buffer Constructors


This topic describes the formats you can use to create a buffer object.

Table 48 describes the buffer constructor arguments that are common to formats A, B, C, and D.

Table 48. Arguments for the Buffer Constructor that Are Common to Formats A, B, C, and D
Argument
Description

unicode

You can use one of the following values:

  • True. Siebel eScript creates the new buffer as a Unicode string regardless of whether the input string is Unicode or not.
  • False. Siebel eScript creates the new buffer as an ASCII string regardless of whether the input string is Unicode or not. False is the default value.

bigEndian

You can use one of the following values:

  • True. Siebel eScript stores the largest data values in the most significant byte.
  • False. Siebel eScript stores the largest data values in the least significant byte. False is the default value.
Format A

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

Table 49 describes the buffer constructor arguments that are specific to format A.

Table 49. Arguments for the Buffer Constructor for Format A
Argument
Description

size

The size of the new buffer that Siebel eScript creates. You can do one of the following:

  • Specify the size argument. Siebel eScript creates the new buffer with the size you specify and fills it with null bytes.
  • Do not specify the size argument. Siebel eScript creates the new buffer with a size of 0. You can configure it to dynamically extend the new buffer later.
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.

Table 50 describes the buffer constructor arguments that are specific to format B.

Table 50. Arguments for the Buffer Constructor for 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:

  • The string is a Unicode string. The size of the buffer is twice the length of the input string.
  • The string is not a Unicode string. The size of the buffer is the length of the input string.

A buffer constructor does not add a terminating null byte at the end of the string.

Format C

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

Table 51 describes the buffer constructor arguments that are specific to format C.

Table 51. Arguments for the Buffer Constructor for 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.

Table 52 describes the buffer constructor arguments that are specific to format D.

Table 52. Arguments for the Buffer Constructor for 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());
   }
}

Siebel eScript Language Reference Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.