variable in a message

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Samuele
Posts: 282
Joined: Mon Oct 11, 2021 7:05 pm

variable in a message

Post by Samuele » Wed Oct 13, 2021 6:59 pm

hello, i've been using livecode for sometime now, i have a question, how can i put a variable into a text message for example "answer your new high score is _gHighScore (a variable) but in a way that it actually works? :roll:
Samuele.

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: variable in a message

Post by Klaus » Wed Oct 13, 2021 7:10 pm

Hi Samuele,

welcome to the forum!
You need to create the appropriate string with & like this:

Code: Select all

...
answer "Your new high score is" && _gHighScore
...
-> & "adds" two strings:
put "text1" & "text" -> text1text2
-> && "adds" two strings with a SPACE:
put "text1" && "text" -> text1 text2

Best

Klaus

Samuele
Posts: 282
Joined: Mon Oct 11, 2021 7:05 pm

Re: variable in a message

Post by Samuele » Wed Oct 13, 2021 7:14 pm

wow, such speed! thanks so much, it worked.
Samuele.

Post Reply