Reverse

(Engine-Level Function)

Description: Returns its parameter with the byte order reversed.
Returns: Varies
Usage: Script or steady state.
Function Groups: String and Buffer
Related to: BuffOrder
Format: Reverse(Type, Value)
Parameters:  
Type
Required. Any numeric expression giving the type of the Value parameter.

Type

Meaning

1

Short

2

Long (32-bit Integers)

3

64-bit Integers

4

Text

Value
Required. Any variable, expression, or constant. It can be of any type except object.
Comments:

If Value is invalid, the return value is invalid.

For type 1, after the bytes are reversed, the result is stored as a 16-bit short integer. If you want an unsigned short for the result, you must AND() it with 0xFFFF. For type 2, the result is stored as a 32-bit signed integer. If you want an unsigned 32bit integer, you must AND() it with 0xFFFFFFFF. For type 3 it is stored as a 64-bit signed integer.

Example:

oldA = 45 { 0b00000000 00101101 };
oldB = "Hello";
newA = Reverse(1, oldA);
newB = Reverse(4, oldB);

The value of newA will be 11 520 which is 0b00101101 00000000. NewB will have a value of "olleH".