Product Information > JADE Encyclopaedia of Classes – Volume 1 > Chapter 1 - System Classes > setExpectedLength

setExpectedLength

setExpectedLength(length: Integer64) updating;

The setExpectedLength method of the JadeBytes class specifies the expected total length of an empty JadeBytes object that will be assembled by using the appendData method. The expected length is taken into account when computing segment size.

Calling this method does not allocate any storage and the length remains set to zero (0).

An exception is raised if the JadeBytes object is not empty when the setExpectedLength method is called. Use the clear or purge method rather than truncate(0) or setContent(null) to empty a JadeBytes object.

The following example shows the use of the setExpectedLength method.

vars
    bytes : JadeBytes;
begin
    create bytes;
    bytes.setExpectedLength(50);
    write bytes.getSegmentSize;  // Writes 256
    bytes.purge;
    bytes.setExpectedLength(1000000);
    write bytes.getSegmentSize;  // Writes 262144
epilog
    delete bytes;
end;