---
title: "ByteString"
canonical: "https://docs.cuesystem.com/space/CVCHELP/510591253/ByteString"
format: markdown
---
> Macro (toc)

---

# Base64ToByteString 

This function converts Base64 to ByteString.  

#### Syntax 

```visualbasic
Function Base64ToByteString ( 
  source As ByteString, 
  ByRef destination As ByteString) 
As Boolean
```

#### Parameters 

source 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the source ByteString. 

destination 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the destination ByteString. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. The function GetLastError returns the error number. 

# ByteStringToBase64 

This function converts ByteString to Base64. 

#### Syntax 

```visualbasic
Function ByteStringToBase64 ( 
  source As ByteString, 
  ByRef destination As ByteString) 
As Boolean
```

#### Parameters 

source 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the source ByteString. 

destination 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the destination ByteString. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. The function GetLastError returns the error number. 

# ByteStringToLowercase 

This function saves a lowercase representation of a **sourcebytestring** to the **destinationbytestring**. Only uppercase letters are converted to lowercase. All lowercase letters and nonletter characters remain unchanged. 

#### Syntax 

```visualbasic
Function ByteStringToLowercase( 
  sourcebytestring As ByteString, 
  ByRef destinationbytestring As ByteString) 
As Boolean
```

#### Parameters 

sourcebytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the source ByteString. 

destinationbytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the destination ByteString. If it is shorter than sourcebytestring, then destinationbytestring is filled by the maximum possible characters and the function returns false. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. The function GetLastError returns the error number.  

# ByteStringToText 

This function converts a source ByteString **srcbytestring** into the destination text **dsttext**. The conversion is from: ASCII, UTF8, or UTF16. 

The function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The errors that can happen: <u>[73](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#73)</u>, <u>[74](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#74)</u>, <u>[75](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#75)</u>, <u>[76](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#76)</u><u>, </u><u>[143](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#143)</u>. 

#### Syntax 

```visualbasic
Function ByteStringToText( 
  srcbytestring As ByteString, 
  ByRef dsttext As Text, 
  conversiontype As Long) 
As Boolean
```

#### Parameters 

srcbytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the source ByteString. 

dsttext 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> It is the destination text. 

conversiontype 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is the type of conversion. Predefined constants for parameter conversiontype are as follows: 

|  |  |
| --- | --- |
| Name | Description |
| _ASCII_TO_TEXT | Conversion from ASCII. |
| _UTF8_TO_TEXT | Conversion from UTF8. |
| _UTF16LE_TO_TEXT | Conversion from UTF16 little-endian. |

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. The function GetLastError returns the error number. 

# ByteStringToTextOnTheFly 

This function converts the bytestring (probably received from the IP channel) to the text. The bytestring buffer does not have to be complete. The function signals if the bytestring data are correct. ByteString data from srcbytestring that are converted are removed after a successful conversion. 

#### Syntax* *

```visualbasic
Function ByteStringToTextOnTheFly( 
  ByRef srcbytestring As ByteString, 
  ByRef dsttext As Text, 
  conversiontype As Long, 
  appendmode As Boolean) 
As Boolean
```

#### Parameters 

srcbytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the source ByteString. 

dsttext 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> It is the destination text. 

conversiontype 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is the type of conversion. The conversion type specifies the format of the source buffer. The possible formats are the same as in the command ByteStringToText.  

appendmode  

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> True - the result text will be appended to the destination text. False-the destination text will be cleared before conversion. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. The GetLastError errors are the same as in the command ByteStringToText plus one more error <u>[144](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#144)</u>. 

# ByteStringToUppercase 

This function saves an uppercase representation of a **sourcebytestring** to the **destinationbytestring**. Only lowercase letters are converted to uppercase. All uppercase letters and nonletter characters remain unchanged. 

#### Syntax 

```visualbasic
Function ByteStringToUppercase( 
  sourcebytestring As ByteString, 
  ByRef destinationbytestring As ByteString) 
As Boolean
```

#### Parameters* *

sourcebytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the source ByteString. 

destinationbytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the destination ByteString. If it is shorter than sourcebytestring, then destinationbytestring is filled by the maximum possible characters and the function returns false. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. The function GetLastError returns the error number. 

# CompareByteString 

This function compares **bytestring1** and **bytestring2** and returns a comparison result. 

The function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The errors that can happen: <u>[67](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#67)</u>, <u>[68](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#68)</u>. 

#### Syntax* *

```visualbasic
Function CompareByteString( 
  bytestring1 As ByteString, 
  bytestring2 As ByteString, 
  Optional flags As Long := _COMPARE_CASESENSITIVE) 
As Long
```

#### Parameters 

bytestring1 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the bytestring1 to compare. 

bytestring2 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the bytestring2 to compare. 

flags 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> Optional, defaults to _COMPARE_CASESENSITIVE. It is the type of comparison. Predefined constants for parameter flags are as follows: 

|  |  |
| --- | --- |
| Name | Description |
| _COMPARE_CASESENSITIVE | Case sensitive comparison. |
| _COMPARE_CASEINSENSITIVE | Case insensitive comparison. |

#### Return value* *

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is a comparison result. Predefined result constants are as follows: 

|  |  |  |
| --- | --- | --- |
| Name | Value | Description |
| _COMPARE_ERROR | 0 | Some error occurs. The error can be tested using the **GetLastError **function. |
| _COMPARE_LESS_THAN | 1 | bytestring1 is less than bytestring2. |
| _COMPARE_EQUAL | 2 | bytestring1 identical to bytestring2. |
| _COMPARE_GREATER_THAN | 3 | bytestring1 is greater than bytestring2. |

# ConcatenateByteString 

This function concatenates bytestrings placed in **ParamArray** and places the result to the **destinationbytestring**. The function returns **true** on success. If an error occurs, then **destinationbytestring** is filled by the maximum possible bytes and the function returns **false**. 

The function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The errors that can happen: <u>[55](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#55)</u>, <u>[56](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#56)</u>, <u>[57](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#57)</u>, <u>[58](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#58)</u>. 

#### Syntax 

```visualbasic
Function ConcatenateByteString( 
  ByRef destinationbytestring As ByteString, 
  ParamArray) 
As Boolean
```

#### Parameters 

destinationbytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the concatenated result. 

ParamArray 

<u>[ParamArray](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/509149361)</u> It is the array of bytestrings to concatenate. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. The function GetLastError returns the error number. 

# FormatByteString 

This function creates a ByteString from parameters listed in ParamArray using the formatting rules **formatbytestring** and places it to the **destinationbytestring**. The function is used for more complex transfer of numbers to a ByteString and its integration into the target ByteString. The function is also suitable for creating chains for ByteString-based communication protocols. 

The function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The errors that can happen: <u>[2](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#2)</u>, <u>[3](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#3)</u>, <u>[4](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#4)</u>, <u>[5](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#5)</u>, <u>[6](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#6)</u>, <u>[8](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#8)</u>, <u>[9](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#9)</u>, <u>[10](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#10)</u>, <u>[11](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#11)</u>, <u>[12](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#12)</u>, <u>[13](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#13)</u>, <u>[14](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#14)</u>, <u>[15](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#15)</u>, <u>[32](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#32)</u>, <u>[33](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#33)</u>, <u>[34](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#34)</u>, <u>[35](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#35)</u>, <u>[36](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#36)</u>, <u>[37](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#37)</u>, <u>[38](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#38)</u>, <u>[39](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#39)</u>. 

#### Syntax 

```visualbasic
Function FormatByteString( 
  ByRef destinationbytestring As ByteString, 
  formatbytestring As ByteString, 
  ParamArray) 
As Boolean
```

#### Parameters 

destinationbytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the destination ByteString to which the result of the format will be stored. 

formatbytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the format ByteString, which sets rules on the format, which will be applied to the variable parameters. See the [Format ByteString specification](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/512328011). 

ParamArray 

<u>[ParamArray](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/509149361)</u> It contains parameters to be formatted (converted to ByteString) and inserted into the destinationbytestring. These values can be of different types: Text, ByteString, Boolean, Byte, Char, Long, Double, and Time. Each type can be formatted in different ways. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. The function GetLastError returns the error number. 

# GetByteStringActualLength 

This function returns a value of the current length of a **sourcebytestring **variable. 

The function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The errors that can happen: <u>[53](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#53)</u>. 

#### Syntax 

```visualbasic
Function GetByteStringActualLength(sourcebytestring As ByteString) As Long
```

#### Parameters 

sourcebytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the bytestring. 

#### Return value 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is a length of a **sourcebytestring **variable. 

# GetByteStringDeclaredLength 

This function returns a value of the declared length of the **sourcebytestring** variable. This is helpful for programmers to determine at runtime the length of variables. In addition, it also allows the programmer to build runtime logic so they won’t accidentally try to put too large of a bytestring into the variable. It returns zero if some error occurs. 

The function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The errors that can happen: <u>[54](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#54)</u>. 

#### Syntax 

```visualbasic
Function GetByteStringDeclaredLength(sourcebytestring As ByteString) As Long
```

#### Parameters* *

sourcebytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the bytestring. 

#### Return value 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is a length of a **sourcebytestring **variable. It is zero if an error occurs. 

# GetByteStringLeft 

This function takes the left part of the **sourcebytestring** with a specified **length** and copies it to the **destinationbytestring**. 

The function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The errors that can happen: <u>[43](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#43)</u>, <u>[45](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#45)</u>, <u>[46](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#46)</u>, <u>[47](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#47)</u>. 

#### Syntax 

```visualbasic
Function GetByteStringLeft( 
  sourcebytestring As ByteString, 
  length As Long, 
  ByRef destinationbytestring As ByteString) 
As Boolean
```

#### Parameters 

sourcebytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the source bytestring. 

length 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is the desired length starting from the left position. It must be greater than or equal 0. 

destinationbytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the destination bytestring. If it is shorter than a required part of sourcebytestring, then destinationbytestring is filled by the maximum possible bytes and the function returns false. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. The function GetLastError returns the error number. 

# GetByteStringMiddle 

This function takes the middle part of the **sourcebytestring** beginning on **startposition **with a specified **length **and copies it to the **destinationbytestring**. 

The function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The errors that can happen: <u>[43](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#43)</u>, <u>[44](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#44)</u>, <u>[45](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#45)</u>, <u>[46](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#46)</u>, <u>[47](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#47)</u>, <u>[48](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#48)</u>, <u>[49](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#49)</u>. 

#### Syntax 

```visualbasic
Function GetByteStringMiddle( 
  sourcebytestring As ByteString, 
  startposition As Long, 
  length As Long, 
  ByRef destinationbytestring As ByteString) 
As Boolean
```

#### Parameters 

sourcebytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the source bytestring. 

startposition 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is the starting position within the bytestring. It must be greater than 1. 

length 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is the desired length from the starting position. It must be greater than or equal to 0. 

destinationbytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the destination bytestring. If it is shorter than a required part of sourcebytestring, then destinationbytestring is filled by the maximum possible bytes and the function returns false. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. The function GetLastError returns the error number. 

# GetByteStringRight 

This function takes the right part of the **sourcebytestring** with a specified **length** and copies it to the **destinationbytestring**. 

The function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The errors that can happen: <u>[43](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#43)</u>, <u>[45](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#45)</u>, <u>[46](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#46)</u>, <u>[47](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#47)</u>. 

#### Syntax 

```visualbasic
Function GetByteStringRight( 
  sourcebytestring As ByteString, 
  length As Long, 
  ByRef destinationtbytestring As ByteString) 
As Boolean
```

#### Parameters 

sourcebytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the source bytestring. 

length 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is the desired length starting from the right position. It must be greater than or equal to 0. 

destinationbytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the destination bytestring. If it is shorter than a required part of sourcebytestring, then destinationbytestring is filled by the maximum possible bytes and the function returns false. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. The function GetLastError returns the error number. 

# GetSubByteStringPosition 

This function returns a Long value specifying the position of the first occurrence of **subbytestring** (after optional **fromposition**) within **sourcebytestring**. If the searched bytestring is not found or some error occurs, the function returns zero. 

The function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The errors that can happen: <u>[63](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#63)</u>, <u>[64](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#64)</u>, <u>[65](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#65)</u>, <u>[66](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#66)</u>. 

#### Syntax 

```visualbasic
Function GetSubByteStringPosition( 
  sourcebytestring As ByteString, 
  subbytestring As ByteString, 
  Optional fromposition As Long := 1, 
  Optional casesensitive As Boolean := True) 
As Long
```

#### Parameters 

sourcebytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the source bytestring being searched. 

subbytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the bytestring sought. 

fromposition 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> Optional, defaults to 1. It is the starting position for each search. If omitted, the search begins at the first byte position. 

casesensitive 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> Optional, defaults to True, subbytestring is searched case sensitive. If it is entered as False, subbytestring is searched case insensitive. 

#### Return value* *

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is the **subbytestring **position within the **sourcebytestring**. It is zero if the searched bytestring is not found or some error occurs. 


# IsValidUTF8 

This function checks that source ByteString contains only valid UTF8 characters.  

**This function is available since firmware 20.10**

#### Syntax 

```visualbasic
Function IsValidUTF8 ( 
  src As ByteString) 
As Boolean
```

#### Parameters 

src 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the source ByteString. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True if source ByteString contains only valid UTF8 characters or False otherwise. The function GetLastError returns the error number. 

# NumberToByteString 

This function converts one number into the **destinationbytestring**. Function expected one number (byte, char, long, double, or time) as **ParamArray**. The number is converted in the default format. If you need to convert a number in other formats, it is necessary to use the command **FormatByteString**. 

#### The default format of conversion numeric types to ByteString 

|  |  |
| --- | --- |
| Type | Description |
| Byte | Integral number without a sign. For example "0", "10", "255". |
| Char | One char. For example "a", "A", "Z", "1". |
| Long | Integral number with a sign in case of a negative number. For example "0", "100", "-99". |
| Double | Floating point number with a sign in case of a negative number. A full number of decimal places, if the number is not integral. For example "10", "100.1", "-999.99". |

#### Syntax 

```visualbasic
Function NumberToByteString( 
  ByRef destinationbytestring As ByteString, 
  ParamArray[1])
As Boolean
```

#### Parameters 

destinationbytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the destination. 

ParamArray 

<u>[ParamArray](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/509149361)</u> It is the number to convert. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. The function GetLastError returns the error number. 

# ParseByteString 

This function is designed to convert a ByteString to a number or more numbers. You can specify the ByteString format and pass ByRef ParamArray the right types of parameters to which stores analysis results. 

The function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The errors that can happen: <u>[2](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#2)</u>, <u>[3](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#3)</u>, <u>[4](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#4)</u>, <u>[5](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#5)</u>, <u>[6](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#6)</u>, <u>[8](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#8)</u>, <u>[9](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#9)</u>, <u>[10](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#10)</u>, <u>[11](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#11)</u>, <u>[12](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#12)</u>, <u>[13](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#13)</u>, <u>[14](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#14)</u>, <u>[15](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#15)</u>, <u>[16](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#16)</u>, <u>[17](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#17)</u>, <u>[18](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#18)</u>, <u>[19](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#19)</u>, <u>[20](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#20)</u>, <u>[21](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#21)</u>, <u>[22](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#22)</u>, <u>[23](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#23)</u>, <u>[24](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#24)</u>. 

#### Syntax 

```visualbasic
Function ParseByteString( 
  sourcebytestring As ByteString, 
  formatbytestring As ByteString, 
  ByRef ParamArray) 
As Boolean
```

#### Parameters 

sourcebytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the source ByteString that must meet the formatting rule format. 

formatbytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the description of the format of the source ByteString. It contains formatting items that can be interspersed with free ByteString. If there is a free ByteString, then the position of the source ByteString must be the same free ByteString, otherwise indicated disagreement with the source data format. 

ParamArray 

<u>[ParamArray](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/509149361)</u> They are addresses of target variables, which save the result of the ByteString values. If we are not interested in some values, you can then transmit the position as a parameter Nothing. It is not considered an error, only the underlying value is not saved. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. The function GetLastError returns the error number. 

#### Formatting code of the parameter format 

A format code contains a list of variable formats. Formats are placed in curly brackets. See the <u>[Parse ByteString specification](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/763789318)</u>. The various formats can be interspersed with free ByteString. 

#### Recognition of grammar for a number 

This format represents the number, if the endpoint of a double or flags format is a double, then recognizes a floating point number or floating point number in exponential notation. Otherwise recognizes an integral number. Gaps between the number and sign a number are ignored. See the following grammar. 

#### Recognition of grammar for an integral number 

```visualbasic
LongNumber := [whitespace][sign][whitespace]lineofdigits
```

```visualbasic
Sign := + | - | empty
```

The format can specify what type of numbers should be recognized. If the format is used modifier H, it is enumerated as a hexadecimal number. For modifier B it is enumerated as a binary number. Otherwise, it is enumerated as a decimal number. It is important to distinguish between the sign in the source text (this also applies to binary and hexadecimal numbers) and a modifier/sign regulation in the format - it affects only how the detection of numbers (binary/hexadecimal/decimal). 

#### Recognition of grammar for floating point number 

```visualbasic
DoubleNumber := [whitespace][sign][whitespace]fixpart[dot dotpart[E sign exponent]]
```

#### Limiting the width of each field for each of the source text 

If each number is placed next to each other, it is necessary to specify the width of each field. This is done using the modifier alignment (justification). Only the value of the width of the field from this modifier is used. Recognition is then limited to this width. 

```visualbasic
Var Num1 As Long 
Var Num2 As Long 
Var Num3 As Long 

ParseByteString(&s"123456789", &s"{nj2}{nj3}{nj4}", Num1, Num2, Num3) 
// Num1 = 12, Num2 = 345, Num3 = 6789
```

```visualbasic
Var BString1 As ByteString[50] 
Var BString2 As ByteString[50] 
Var Num1 As Long 
Var Num2 As Long 

ParseByteString(&s"Hello123Boyff", &s"{sj5}{nj3}{sj3}{nhj2}", BString1, Num1, BString2, Num2) 
// BString1 = &s"Hello", Num1 = 123, BString2 = &s"Boy", Num2 = 255 (= &Hff)
```

# SetByteStringActualLength 

This function sets the current length of the **destinationbytestring** according to the parameter **length**. 

The function must be used before the variable length is changed by direct access to the variable's <u>[Bytes](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Byte)</u>: 

```visualbasic
Var b As ByteString[100] := &s"\01\02\03\04\05" // actual length = 5 

SetByteStringActualLength(b, 6) 
// increase actual length to 6 to add one byte at the end 

b[6] := 6 // direct access 
// b contains &s"\01\02\03\04\05\06"
```

The function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The errors that can happen: <u>[50](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#50)</u>, <u>[51](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#51)</u>, <u>[52](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#52)</u>. 

#### Syntax* *

```visualbasic
Function SetByteStringActualLength( 
  ByRef destinationbytestring As ByteString, 
  length As Long) 
As Boolean
```

#### Parameters 

destinationbytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the destination bytestring. 

length 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is the new length. It must be in the range from 0 to the declared length of the text. 

#### Return value* *

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. The function GetLastError returns the error number. 

# TrimByteString 

This function saves a **sourcebytestring **without leading and trailing bytes specified in** trimchars** into the **destinationbytestring**. If the optional **trimchars** parameter is not used, the default value (space byte) is used for trimming. 

The function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The errors that can happen: <u>[59](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#59)</u>, <u>[60](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#60)</u>, <u>[61](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#61)</u>, <u>[62](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#62)</u>. 

#### Syntax 

```visualbasic
Function TrimByteString( 
  sourcebytestring As ByteString, 
  ByRef destination As ByteString, 
  Optional trimbytes As ByteString := &S" ") 
As Boolean
```

#### Parameters 

sourcebytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the source bytestring. 

destinationbytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the destination bytestring. If it is shorter than sourcebytestring, then destinationbytestring is filled by the maximum possible bytes and the function returns false. 

trimchars 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional, defaults to &S" ". It specifies the trim bytes. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. The function GetLastError returns the error number. 

# TrimByteStringLeft 

This function saves a **sourcebytestring **without leading bytes specified in** trimchars** into the **destinationbytestring**. If the optional **trimchars** parameter is not used, the default value (space byte) is used for trimming. 

The function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The errors that can happen: <u>[59](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#59)</u>, <u>[60](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#60)</u>, <u>[61](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#61)</u>, <u>[62](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#62)</u>. 

#### Syntax* *

```visualbasic
Function TrimByteStringLeft( 
  sourcebytestring As ByteString, 
  ByRef destination As ByteString, 
  Optional trimbytes As ByteString := &S" ") 
As Boolean
```

#### Parameters 

sourcebytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the source bytestring. 

destinationbytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the destination bytestring. If it is shorter than sourcebytestring, then destinationbytestring is filled by the maximum possible bytes and the function returns false. 

trimchars 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional, defaults to &S" ". It specifies the trim bytes. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. The function GetLastError returns the error number. 

# TrimByteStringRight 

This function saves a **sourcebytestring **without trailing bytes specified in** trimchars** into the **destinationbytestring**. If the optional **trimchars** parameter is not used, the default value (space byte) is used for trimming. 

The function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The errors that can happen: <u>[59](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#59)</u>, <u>[60](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#60)</u>, <u>[61](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#61)</u>, <u>[62](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#62)</u>. 

#### Syntax 

```visualbasic
Function TrimByteStringRight( 
  sourcebytestring As ByteString, 
  ByRef destination As ByteString, 
  Optional trimbytes As ByteString := &S" ") 
As Boolean
```

#### Parameters 

sourcebytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the source bytestring. 

destinationbytestring 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> It is the destination bytestring. If it is shorter than sourcebytestring, then destinationbytestring is filled by the maximum possible bytes and the function returns false. 

trimchars 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional, defaults to &S" ". It specifies the trim bytes. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. The function GetLastError returns the error number.