Enter multiline text into a text box via script

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
SheyMouse
Posts: 9
Joined: Sat Jan 17, 2015 1:06 am

Enter multiline text into a text box via script

Post by SheyMouse » Wed Jan 28, 2015 5:42 pm

Hello,

I am attempting to script the placement of multiline text into a field when a user presses a button. It's probably my syntax knowledge that is letting me down (and my google-fu).
The scenario is when a user presses a button
This is copied into a field

Code: Select all

Line one of the text
Line two of the text
Line three
In other languages there are escape characters such as "/n" which would insert new line. So the string would be something like:

Code: Select all

"Line one of the text /n Line two of the text /n Line three"
[/i]

Could someone please let me know how the above would be structured in Livecode. I know it's

Code: Select all

put the text "foo" into the field "bar"
but how can I structure "foo"?

Klaus
Posts: 13878
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Enter multiline text into a text box via script

Post by Klaus » Wed Jan 28, 2015 5:48 pm

Hello SheyMouse,

a new line is "made" with CR in Livecode, so do this:
...
put "This is line 1" & CR & "This is line 2" & CR & "This is line 3" into foo
put foo into fld "wherever"
...

Best

Klaus

P.S.
Did you already check these great stacks:
http://www.hyperactivesw.com/revscriptc ... ences.html

sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: Enter multiline text into a text box via script

Post by sefrojones » Wed Jan 28, 2015 5:48 pm

try this:

Code: Select all

put "Line one of the text" & cr & "Line two of the text" & cr & "Line three" into field "bar"
CR = carriage return


HTH,

--Sefro

edit: As usual, Klaus was quickest on the draw. :)

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”