Join String

 

At times it may be appropriate to assign more than one value to a single variable. In such instances, create a variable that contains a series of values. This series is called a variable array. If the variable is named "sales", then the array elements would be designated as %sales[1]%, %sales[2]% and so on up to the number of elements defined in the array.

 

Array elements start with [1] and not [0]. Each element stores a distinct value. The Join String command is used to combine multiple elements of an array into a single variable. 

 

 

Script Editor > Expand Variables Category > Join String

 

 

Variable Array to Join

Select the variable array from which the array elements are combined into a single variable.

 

 

Starting Element

Select the first element that is to be joined into a single variable.

 

 

Ending Element

Select the last element of the array variable to combine into the single variable.

 

 

Join the Strings With

Insert a character or text as a separator for each of the elements when combined into a single variable. Insert a space, a comma, a hyphen or any type text required. Or leave the field blank for no separation between elements.

 

 

Destination

Select the text string variable to store the combined variable elements.

 

 

Example

Assume a macro is using the ASCII File Begin Process command. The text file has 10 records on each line. The first record is saved to T[1], the second to T[2] and so on through T[10]. Record one contains a first name, record two a middle name and record three the last name. The remaining records contain address and phone information.

 

Our objective is to combine the three names into a single string, which the Join String command does quite easily. In this case we just need a space between each of the names, so that the names are not one long jumble. The image above shows how this would be done.

 

In the Join the Strings With edit box, place the cursor to the far left of the box and press the Space Bar once. This instructs the macro to separate each of the elements with a space.

 

So in our example, John is saved to T[1], Michael is saved to T[2] and Smith is saved to T[3]. The Join String command then saves John Michael Smith to variable %Name%.