Skip to content

StrJoinFromArray

See Also: Array Functions, Array Variable Assignments, String Functions, Working with Arrays, StrSplitToArray

Purpose

Appends contents of elements of a String array to a single String.

Return Type

String

Syntax

StrJoinFromArray( {StringArray}, {Delimiter} )

Where:

  • {StringArray} is the DataFlex String array containing the elements to append.
  • {Delimiter} is used to separate the appended strings. It can be any ASCII character, e.g., comma (,), period (.), etc. You can use "" if you do not want the resulting String to be delimited.

What it Does

StrJoinFromArray appends all elements in a String array to a single String, separated by the specified delimiter.

Example

This sample appends the elements in the String array Flintstones to the String variable sNames, separated by commas: "Fred,Wilma,Betty,Barney".

Procedure Test
    String[] Flintstones
    String sNames

    Move "Fred" to Flintstones[0]
    Move "Wilma" to Flintstones[1]
    Move "Betty" to Flintstones[2]
    Move "Barney" to Flintstones[3]

    Move (StrJoinFromArray(Flintstones, ",")) to sNames
End_Procedure

Note that the resulting String is in the same order as the elements in the source array. If you would like the resulting string to be sorted, you need to sort the array (using SortArray) before calling StrJoinFromArray. The result will be: "Barney,Betty,Fred,Wilma".

Procedure Test
    String[] Flintstones
    String sNames

    Move "Fred" to Flintstones[0]
    Move "Wilma" to Flintstones[1]
    Move "Betty" to Flintstones[2]
    Move "Barney" to Flintstones[3]

    Move (SortArray(Flintstones)) to Flintstones
    Move (StrJoinFromArray(Flintstones, ",")) to sNames
End_Procedure