Pages: 1
I'm new to scratch, but old to programming.
Was writing a demo prog with the kids. Really simple.
Cat (sprite 1) says, Hi What is your name? and gets an answer.
answer is pout into variable called yourname
Cat wants to say "Hello " <yourname>.
I checked on the forums, couldn't find any way of going
Say "Hello" + yourname.
Saw lots of people saying it is not easy. Here is my question nad an idea.
1 - Is there a way of doing this yet or is it still not possible to concatenate strings in a Say block?
2 - If answer one above is no - here is my tip.
when gf clicked ask "what is your name?" and wait Set <yourname> to <answer> Say Join "Hello " + <yourname>Join allows real time concatenation of strings and using them.
Offline
There's already a block for that, since 1.4 c: It's the "join" block (just as you said), under "Operators":
say (join [Hello, ](join (name)[!]))
Offline
vbconz wrote:
I'm new to scratch, but old to programming.
Was writing a demo prog with the kids. Really simple.
Cat (sprite 1) says, Hi What is your name? and gets an answer.
answer is pout into variable called yourname
Cat wants to say "Hello " <yourname>.
I checked on the forums, couldn't find any way of going
Say "Hello" + yourname.
Saw lots of people saying it is not easy. Here is my question nad an idea.
1 - Is there a way of doing this yet or is it still not possible to concatenate strings in a Say block?
2 - If answer one above is no - here is my tip.
when gf clicked ask [what is your name?] and wait Set [yourname v] to (answer) Say (Join [Hello ] (yourname)>Join allows real time concatenation of strings and using them.
Well, yes, there is a way to connect text and a variable together; in fact, you're already using it in your tip! It's the (join [] []) block! In fact, you can even use multiple join blocks inside of join blocks. For example:
when gf clicked say (join (join [Hello! It's nice to meet you, Mr.] (Answer)) [! I earlier heard that you became a millionaire. Is that correct?])
Offline
Pages: 1