Description
Re-orders the bytes in a byte stream to convert from a big-endian to a little-endian, or vice versa. This will reverse the order of the characters in the calling String.
Timing Precision Mode
This page describes functionality in millisecond timing precision mode. Millisecond timing precision mode is deprecated and will be removed in a future release. We recommend that you migrate your Mission Plans to nanosecond timing precision mode.
Click here to see the documentation for this object in nanosecond timing precision mode.
Method Signature
String.SwapBytes(
|
Variable numberOfBytes)
|
Arguments
numberOfBytes
|
|
Description:
|
The number of bytes (characters), measured from the beginning of the stream, that will be converted into reverse order ("swapped"). To swap an entire string, this should be equal to the length of the string.
|
Valid Range:
|
numberOfBytes > 0
|
Return Value
Returns a String containing the re-ordered byte stream.
Syntax
myString1 = myString2.SwapBytes(myVariable1);
|
The following example demonstrates the use of the String.SwapBytes method. The variable entered as an input argument determines the number of characters, measured from the beginning of the string, that will be converted into reverse order ("swapped").
String alpha = "alphabet";
Report alpha.SwapBytes(1), alpha.SwapBytes(4), alpha.SwapBytes(6), alpha.SwapBytes(8);
|
Output:
|
The following example demonstrates the use of the String.SwapBytes method. To swap an entire string, this input Variable should be equal to the length of the string.
String alpha = "alphabet";
Report alpha.SwapBytes(alpha.Length), alpha.SwapBytes(alpha.Length).SwapBytes(alpha.Length);
|
Output:
|
The following example demonstrates that calling the SwapBytes method on the result of a previous "swap" will return the characters to their original order.
String alpha = "alphabet";
Report alpha.SwapBytes(8).SwapBytes(8);
|
Output:
|
See also
String Object
Parsing Dates and Times
Parsing Arbitrary String Data
Parsing Arbitrary String Data
|