Document stub.png 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)
Custom blocks allow for a flexible method to easily compile a list into a string. For this tutorial, a block called "compile list into string separated by (char)" will be used, in which the block takes every item in a list and compiles it into a string, separating each item with (char). 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

Additionally, a list will be needed, containing the items to be compiled.

Scripting

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 [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)
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.