Skip to content

UCharArrayToString

See Also: Array Functions, Array Variable Assignments, String Functions, Working with Arrays, StringToUCharArray, UCharArrayToString, UCharToWString, WStringToUCharArray

Purpose

Returns a DataFlex string which is a copy of the passed UChar array.

Return Type

String

Syntax

UCharArrayToString({UCharArray})
UCharArrayToString({UCharArray}[, {size}])
UCharArrayToString({UCharArray}[, {size}[, {offset}])

Where:

  • {UCharArray} is a single dimension UChar[].
  • {size} limits the number of array items added to the string (so it equals the number of bytes, which is not the number of characters).
  • {offset} determines at which array item to start (0-based).

What it Does

  • UCharArrayToString returns a DataFlex string which is a copy of the passed single-dimension UChar array.
  • If {size} is passed, only {size} number of bytes of the array are copied to the string.
  • If {size} and {offset} are passed, only {size} number of bytes of the array are copied to the string, starting at array item {offset} (0-based).

Examples

This sample copies all bytes from the UChar array uaMyString to the DataFlex string sValue, resulting in sValue containing the value "Testing".

Procedure Test
    UChar[] uaMyString
    String sValue
    Move (Ascii("T")) to uaMyString[0]
    Move (Ascii("e")) to uaMyString[1]
    Move (Ascii("s")) to uaMyString[2]
    Move (Ascii("t")) to uaMyString[3]
    Move (Ascii("i")) to uaMyString[4]
    Move (Ascii("n")) to uaMyString[5]
    Move (Ascii("g")) to uaMyString[6]
    Move (UCharArrayToString(uaMyString)) to sValue
End_Procedure

This sample copies the first 4 bytes from the UChar array uaMyString to the DataFlex string sValue, resulting in sValue containing the value "Test".

Procedure Test
    UChar[] uaMyString
    String sValue
    Move (Ascii("T")) to uaMyString[0]
    Move (Ascii("e")) to uaMyString[1]
    Move (Ascii("s")) to uaMyString[2]
    Move (Ascii("t")) to uaMyString[3]
    Move (Ascii("i")) to uaMyString[4]
    Move (Ascii("n")) to uaMyString[5]
    Move (Ascii("g")) to uaMyString[6]
    Move (UCharArrayToString(uaMyString, 4)) to sValue
End_Procedure

This sample copies 4 bytes from the UChar array uaMyString to the DataFlex string sValue, starting at array item 2, resulting in sValue containing the value "stin".

Procedure Test
    UChar[] uaMyString
    String sValue
    Move (Ascii("T")) to uaMyString[0]
    Move (Ascii("e")) to uaMyString[1]
    Move (Ascii("s")) to uaMyString[2]
    Move (Ascii("t")) to uaMyString[3]
    Move (Ascii("i")) to uaMyString[4]
    Move (Ascii("n")) to uaMyString[5]
    Move (Ascii("g")) to uaMyString[6]
    Move (UCharArrayToString(uaMyString, 4, 2)) to sValue
End_Procedure