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

3

Not supported

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.

After the bytes are reversed, the result is cast to a W_SHORT. If you want an unsigned short for the result, you must AND() it with 0xFFFF.

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".