Concatenation Question

You know the Concatenation command?

*set VARIABLE “word”&“word”

Then VARIABLE would be “wordword”, right? Well, my question is, would this work:

*set VARIABLE1 “dog”
*set VARIABLE2 “days”
*set VARIABLE1 “{VARIABLE1}" & "{VARIABLE2}”

Would that give me a VARIABLE1 “dogdays”?

Thanks guys!

From here:

Curly parens: Put some text in curly braces and we’ll turn it into the value of the named variable.
*set honesty 30
*set virtue “honesty”
*set score {virtue}
Your {virtue} score is {score}

Not sure how this interplays with concatenation and other complex coding, but assuming it works like it’s appears it’s supposed to in every other case, that last line should be:
*set VARIABLE1 {VARIABLE1} & {VARIABLE2}

Other than that though, I think it should work fine.

1 Like
*set variable1 variable1&variable2

No curly parentheses here, that’d make it look for variables named ‘dog’ and ‘days’ - it can be a little confusing.

Further reading: http://choicescriptdev.wikia.com/wiki/Concatenation

1 Like

Alright! Thanks guys.

On a side note, so does it work to use a variable twice in a command like that, like I was doing with VARIABLE1?

you mean this?

*set VARIABLE1 “{VARIABLE1}" & "{VARIABLE2}”

I’m gonna say probably, but let me test it…

*create Ts “Hmm.”
*create Ts2 " Huh??"

*set Ts Ts & Ts2
${Ts}

It worked. It gave me “Hmm. Huh??”

1 Like

AWESOME!!! That’s great news. Thank you guys!!