To reverse a string (text), the letters must be arranged backwards.

Hello world! becomes !dlrow olleH

12345 becomes 54321

Scratch On! becomes !nO hctarcS


Scripts

There are various scripts to reverse a string. Below are two scripts to reverse a string.


Script 1

This script is the fastest script (by about 5% compared to Script 2)

define reverse text (str)
set [output v] to []
repeat (length of (str))
set [output v] to (join (letter ((length of (output)) + (1)) of (str)) (output))
end


Script 2

define reverse text (str)
set [index v] to (0)
set [output v] to []
repeat (length of (str))
change [index v] by (1)
set [output v] to (join (letter (index) of (str)) (output))
end


How to Use

To reverse text with the code, simply run the custom block with its parameter set to the text.

reverse text [en.scratch-wiki.info]:: custom

The output will be returned in the (output) block.