(Redirected from () Contains ()? (block))
- "() Contains ()" redirects here. For the list block, see () Contains ()? (List block).
|() Contains ()?|
() contains ()?
The () contains ()? block is a boolean block and an operators block. The block returns whether or not the first parameter's text contains the second parameter's text. The comparison is not case-sensitive.
Checking whether input contains a certain string - useful for soft-checking as the actual input may not be exactly identical:
when green flag clicked switch costume to (bunny v) ask [What's this animal?] and wait if <(answer) contains [bunny]?> then // the contains block is used instead of equal to because the user might say "a bunny" say [Correct!] else say [Nope!] end
This block is not case sensitive. For example:
<[apple banana] contains [apple]?> // reports true <[apple banana] contains [APPLE]?> // reports true <[apple banana] contains [Apple]?> // reports true
If the second Argument is empty, this block will always report true.
- Main article: List of Block Workarounds
define (string1) contains (string2)::custom set [i v] to  set [j v] to  repeat (length of (string1)) change [i v] by (1) if <(letter (i) of (string1)) = (letter (j) of (string2))> then set [j v] to  repeat until <<not <(letter ((i) + (j)) of (string1)) = (letter (j) of (string2))>> or <(j) > (length of (string2))>> change [j v] by (1) end if <(j) > (length of (string2))> then set [result v] to [true] stop [this script v] end end end
() + () • () - () • () * () • () / () • Pick Random () to () • () < () • () = () • () > () • () and () • () or () • Not () • Join ()() • Letter () of () • Length of () • () Mod () • Round () • () of ()More blocks...
The Wiki is working on a dark theme, and you're seeing it! Got feedback? Post on the Wiki Forum Topic.