BuffOrder

(Engine-Level Function)

Description: Reverses the order of groups of bytes in a buffer, and returns a new (rearranged) buffer.
Returns: Buffer
Usage: Script or steady state.
Function Groups: String and Buffer
Related to: BuffRead | BuffWrite | Replace | Reverse | ParmToBuff | BuffToParm
Format: BuffOrder(Buffer, Offset, Size, Increment, N)
Parameters:  
Buffer
Required. Any text or buffer expression to be reordered.
Offset
Required. Any numeric expression giving the initial position within the buffer for the ordering, starting at 0. Offset must be greater than or equal to 0.
Size
Required. Any numeric expression greater than 0, giving the size of each group of bytes. Bytes within a group will remain in their original order. The portion of the original buffer that will be re-ordered must be evenly divisible into groups of Size.
Increment
Required. Any numeric expression greater than 0, giving the number of groups of Size bytes to be reordered. Re-ordering is done to the Size-groups within Increments, not across Increments.
N
Required. Any numeric expression giving the total number of Increment-groups to reverse.

Comments:

BuffOrder is part of the driver toolkit. The return value is a buffer containing all bytes specified in the Buffer parameter with groups of bytes reversed. Offset + Size * Increment * N must be no greater than the length of Buffer. Returns Invalid if any parameter does not meet its requirements.

BuffOrder is useful for altering buffers for use with the ParmToBuff or BuffToParm functions.

Example:

  Buff1 = BuffOrder("0123456789" { Buffer },
                    0 { Starting offset },
                    1 { Size of group },
                    10 { groups in shuffle },
                    1 { Number of repetitions });

In this example, Buff1 will be equal to "9876543210".

  Buff2 = BuffOrder("0123456789" { Buffer },
                    2 { Starting offset },
                    1 { Size of group },
                    2 { Groups in shuffle },
                    4 { Number of repetitions });

 In this example, Buff2 will be equal to "0132547698".