join () ()

From PenguinMod Wiki (Official)
Join () ()
Jump to navigation Jump to search

The join () () block is a reporter block that concatenates the two given strings together. It originates from Scratch. The first and second inputs have default values of "apple " and "banana", respectively (which results in the string "apple banana" being reported).

It can be used to figure out the value of variables or reporters (with a label to differentiate), use time, to negate positive numbers, and showing more decimals in speech blocks:[1]

join (variable 1) (variable 2) //results in the 2 variables being joined without spaces

join [current volume on sprite: ] ([volume v] of (sprite v)) //results in "current volume on sprite: [VOLUME]"

join [-] (positive num::grey)

Workaround

This block can be worked around with the following:[1]

define join (string 1) (string 2)
delete all of [temp list v]
set [count] to [0]::#0869c2
repeat (length of (string 1))
change [count] by (1)::#0869c2
add (letter (get [count]::#0869c2) of (string 1)) to [temp list v]
end
set [count] to [0]::#0869c2
repeat (length of (string 2))
change [count] by (1)::#0869c2
add (letter (get [count]::#0869c2) of (string 2)) to [temp list v]
end
return (temp list)::custom cap

This workaround works because in Scratch (with regular variables) and PenguinMod, the () lists reporter reports items without spaces if the characters are 1 character long.
It can also be worked around using join () () () or its variants, and having every input after the 2nd be a blank string:

define join (string 1) (string 2)
return (join (string 1) (string 2) []::operators)::custom cap

See also

References