|This article is a stub. It may be incomplete, unfinished, or have missing parts/sections. If the article can be expanded, please do so! There may be suggestions on its talk page. (June 2018)|
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:
Additionally, a list will be needed, containing the items to be compiled.
The following script compiles every item in a list called "list" into the string "result".
define compile list into string separated by (char) set [i v] to  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) end
In your own scripts, change "list" to whatever list you need to compile.
How it Works
This is a basic method to combine a list into a string. It's mechanics are simple and easy to understand. 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.
In the following method, you can not pick the separating character, it is automatically set to a space.
set [result v] to (list :: list)