Custom blocks allow for a method for compiling a list into a string. For this tutorial, a custom block will be used, in which the block takes every item in a list and compiles it into a string, separating each item with an inputed value. For example, if a user has a list containing the following items:

  • apple
  • orange
  • lime

and a user uses this block with the separator ";", the result will be "apple; orange; lime; ".

For this tutorial, the following variables will be needed:

  • (i)
  • (result)

A list will also be needed:

  • (list::list)//the list where the items that need to be separated are

The following custom block will be needed:

  • define compile list into string separated by (char)


The following script compiles every item in the list (list::list) into the variable (result).

define compile list into string separated by (char)
set [i v] to [0]
set [result v] to []
repeat (length of [list v])
  change [i v] by (1)
  set [result v] to (join (join (result) (item (i) of [list v])) (char)) // add one letter of the list item to (result)

The (list::list) variable can be interchanged for any variable or name that the user wants to use in their own script.

How it Works

This is a method to combine a list into a string. The variable (i) is an integer variable which stores the number in the list that is going to be added to the string.

The script uses a loop (repeat) to continuously add a different value from the list to the string using:

  set [result v] to (join (join (result) (item (i) of [list v])) (char))

and the variable (i)'s value is increased by 1 in every iteration of the loop.

Other Methods

In the following method, one can not pick the separating character; it is automatically set to a space, unless the list consists entirely of single-digit positive integers, in which case there is no seperator.

set [result  v] to (list::list)
Cookies help us deliver our services. By using our services, you agree to our use of cookies.