# hexstring

The keyword hexstring denotes a basic string type whose distinguished values are the ordered sequences of of hexadecimal digits, each corresponding to an ordered sequence of four bits.

- hexadecimal string values are written between single quotes and followed by the capital letter H. (' 'H).
- A hexadecimal string may be specified by its integer value using a conversion function.
- The relational operators equality (==) and non-equality (!=) can be used to compare values of two hexadecimal strings
- The shift operators perform the shift left (<<) and shift right (>>) operations.
- The rotate operators perform the rotate left (<@) and rotate right (@>) operations.
- The concatenation operator (&) performs a simple concatenation from left to right.
- Bitwise operators (and4b, not4b, or4b, xor4b) are used to manipulate bits in the string.
- A single octet may be accessed using an array-like syntax. The leftmost octet has the index zero.
- The hexadecimal string may be empty.
- The length of the hexadecimal string can be constrained using the keyword length.
- Another way to limit the permitted values of an hexadecimal string is to list them.
- Predefined functions operating on hexadecimal strings:

- hex2oct converts a hexadecimal string value to an octet string.
- hex2int converts a hexadecimal string to the equivalent integer.
- hex2bit converts a hexadecimal string to a binary string.
- hex2str displays a hexadecimal string as a character string.
- lengthof returns an integer value indicating the number of octets in a string.

Related keyword:

- bit2hex
- hex2bit
- hex2int
- hex2oct
- hex2str
- int2hex
- length
- lengthof
- oct2hex
- str2hex
- substr
- and4bit
- not4bit
- or4bit
- xor4bit

### hexstring

Example 1:

const hexstring c_elch := 'C'H;

The constant called c_elch contains the hexadecimal string C.

Example 2:

const hexstring c_entiere := int2hex (64,3);

The constant c_entiere will contain the hexadecimal string 040 because the converted integer number (64 -> 40) must be coded on 3 hexadecimal digits and therefore padded with a leading zero.

Example 3:

const boolean c_undanbedes := ( c_entiere == c_elch );

The constant c_undanbedes will have the value false, because two hexadecimal strings are not equal. The parentheses are optional.

Example 4:

const hexstring c_samman := c_entiere & c_elch;

The constant c_samman will contain the hexadecimal string 040C

Example 5:

const hexstring c_lakomec := c_entiere[1];

The constant called c_lakomec will contain the hexadecimal string 4.

Example 6:

const hexstring c_tomt := ''H;

The constant called c_tomt will be an empty string.

Example 7a:

const octetstring c_kaprifol := hex2oct ('7AA'H);

The constant called c_kaprifol will contain the octet string 07AA. The resulting octet string contains 0 as leftmost hex digit followed by the same sequence of hex digits as in the hexadecimal string because the number of the hexadecimal digits is odd.

Example 7b:

const integer c_gondol := hex2int ('555'H);

The constant called c_gondol will have the integer value 1365. The result will be always positive.

Example 7c:

const bitstring c_perrongen := hex2bit ('A7'H);

The constant called c_perrongen will contain the bit string 10100111.

Example 7d:

const charstring c_snaella := hex2str ('BBC0530A0'H);

The constant called c_snaella will contain the string BBC0530A0 because the resulting character string has the same length as the hexadecimal string and contains only the characters '0' .. 'F'.

Example 7e:

const integer c_skynda := lengthof ('BBC0530A0'H);

The constant called c_skynda will have the value 9 corresponding to the number of octets in the string.

Example 8:

var hexstring c_mot ('010'H,'77'H,'A55CC'H );

The variable called c_mot may hold the hexadecimal strings 010, 77 and A55CC only.

Example 9:

const hexstring c_koerhinta := '12345'H @> 2;

The constant called c_koerhinta will hold the value '45123'H (the left operand rotated by two hexadecimal digits).

Example 10:

const hexstring c_wet := '12345'H >> 2;

The constant called c_wet will hold the value '00123'H (the left operand shifted by two hexadecimal digits).

BNF definition of hexstring
BNF definition of hexstring value