ConvertBytesToCount Data Member Function

Sets the array count to a value guaranteed to be large enough to store an array of N bytes. Will round up to the nearest positive <int32> if the byte count provided does not align with the number of bytes per element. For example, <float64> values are 8 bytes each, so providing a value of 16 bytes ensures the array count is set to 2. Similarly, providing a value of 17 bytes, which is not a multiple of 8, ensures the array count is set to 3.

Prototype

int32 ConvertBytesToCount( int32 p_nCount )

Parameters

Parameter Type Parameter Name Documentation
int32p_nCountThe number of bytes you wish to convert to an array count.

Examples

Copy Text To Clipboard

import library "app_service_console_util.ssl";
import library "type_color_array_util.ssl";

int base = 4; // min 4 bytes per Color object.

auto ColorArray a;
a.ConvertBytesToCount( base + 2 ); // Rounds up to 8 bytes...
LibColorArray.Out( a ); // Prints 'garbage' values since uninitialized...

Console.Out( "---" );

a.ConvertBytesToCount( 16 );
LibColorArray.Out( a ); // Prints 'garbage' values since uninitialized...

Results

COLORARRAY OUTPUT generated by TYPE_COLOR_ARRAY_UTIL.SSL
6,
2,
0,
3,
6,
3,
6,
101
---
COLORARRAY OUTPUT generated by TYPE_COLOR_ARRAY_UTIL.SSL
6,
2,
0,
3,
6,
3,
6,
101,
0,
1,
6,
102,
6,
114,
0,
3