Put large text into a variable

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
Val_UK
Posts: 7
Joined: Fri Jul 22, 2011 3:19 pm

Put large text into a variable

Post by Val_UK » Fri Jul 22, 2011 3:23 pm

Hi, I need to be able to put something like a text below into a variable

"My name is Val.

I live in New Orleans.

I love seafood."

I know how to put a single line text into a variable - put "My name is Val" into myVar1. I am a little bit confused about how to do the same thing with a multi line text (see above).

Any help is very appreciated.

Val

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

Re: Put large text into a variable

Post by Klaus » Fri Jul 22, 2011 3:30 pm

Hi Val,

welcome to the forum! :D

Just add a RETURN (or shorter CR) to your strings!
...
put "My name is Val." & CR & CR & "I live in New Orleans." & CR & CR & "I love seafood." into myVar
answer myVar
...
Will give:
My name is Val.

I live in New Orleans.

I love seafood.


Best

Klaus

P.S.
check these stacks, great learning resources!
http://www.runrev.com/developers/lesson ... nferences/

Val_UK
Posts: 7
Joined: Fri Jul 22, 2011 3:19 pm

Re: Put large text into a variable

Post by Val_UK » Fri Jul 22, 2011 3:44 pm

Hi, Klaus,
Thank you for the help. One more related question - if this line becomes too long, how can I start a new line without breaking the code?
Thank you.
Val

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

Re: Put large text into a variable

Post by Klaus » Fri Jul 22, 2011 4:00 pm

Hi Val,

you mean in the script editor?

You can use a BACKSLASH as a not_breaking_the_code_new_line :D

Like this:

Code: Select all

...
put "This is a very very long line that will surely make reading extremely difficult and " & \
     "is a pain to script in this script editor, but there is the handy BACKSLASH!" into myVar
 ...
will result in ONE line in the variable.
You get the picture!


Best

Klaus

Val_UK
Posts: 7
Joined: Fri Jul 22, 2011 3:19 pm

Re: Put large text into a variable

Post by Val_UK » Fri Jul 22, 2011 5:21 pm

Thank you, Klaus!

Post Reply