Scimonster (talk | contribs) m (→Offline decimal trick: Transcribed the other in a comment, we'll wait 'til the padding bug gets fixed before moving it out.) |
m (Improved some of the wording) |
||
Line 9: | Line 9: | ||
|added = 1.4 | |added = 1.4 | ||
}} | }} | ||
− | The '''Join ()()''' [[Blocks|block]] is an [[Operators Blocks|Operators block]] and a [[Reporter Block|Reporter block]]. The block | + | The '''Join ()()''' [[Blocks|block]] is an [[Operators Blocks|Operators block]] and a [[Reporter Block|Reporter block]]. The block concatenates, or "links" the two values together and reports the result {{-}} for example, if "hello" and "world" were put in the block, it would report "helloworld". To report "hello world", use either "hello " and "world" or "hello" and " world", with a space. |
==Workaround== | ==Workaround== | ||
Line 29: | Line 29: | ||
==Example Uses== | ==Example Uses== | ||
− | If words, numbers, sentences {{-}} any two values {{-}} must be | + | If words, numbers, sentences {{-}} any two values {{-}} must be concatencated together, this block easily does the job. |
Some common uses for the '''Join ()()''' block: | Some common uses for the '''Join ()()''' block: | ||
− | * | + | *Joining words and variables to create a sentence |
<scratchblocks> | <scratchblocks> |
Revision as of 03:00, 18 January 2012
Join ()() | |
![]() | |
Category | Operators |
Type | Reporter |
Introduced in | 1.4 |
The Join ()() block is an Operators block and a Reporter block. The block concatenates, or "links" the two values together and reports the result — for example, if "hello" and "world" were put in the block, it would report "helloworld". To report "hello world", use either "hello " and "world" or "hello" and " world", with a space.
Workaround
This block can be replicated with the following code:
set [count v] to [0] repeat (length of (insert1)) change [count v] by (1) add (letter (count) of (instert1)) to [final v] end set [count v] to [0] repeat (length of (insert2)) change [count v] by (1) add (letter (count) of (insert2)) to [final v]
The list "final" contains the result.
Example Uses
If words, numbers, sentences — any two values — must be concatencated together, this block easily does the job.
Some common uses for the Join ()() block:
- Joining words and variables to create a sentence
when flag clicked ask [What's your name?] and wait say (join (join (join [Hello ] (answer))[. My name is ]) (Person's name))
- Place a variable in a message (eg. "You completed 2 loops")
- An easy method of making a positive number turn negative (placing "-" in the first input and the positive number in the second)
Offline decimal trick
Offline, numbers in variables and speech bubbles usually round to only two decimal places. In some projects, it is necessary to have more. Placing the calculation in one input of the Join ()() block and leaving the other input empty 'magically' reports the number with more decimal places.
- The original script:
set [number v] to ([sqrt v] of ((item (1 v) of [list v]) * (3)))
- Script with more decimals:
set [number v] to (join([sqrt v] of ((item (1 v) of [list v]) * (3))) [])
- To set the number of decimal places, use a script like this:
() + () • () - () • () * () • () / () • Pick Random () to () • () < () • () = () • () > () • () and () • () or () • Not () • Join ()() • Letter () of () • Length of () • () Mod () • Round () • () of ()More blocks...
|