How can I make a line break within a string in code

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Joerg
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 21
Joined: Sun Dec 20, 2009 12:35 am

How can I make a line break within a string in code

Post by Joerg » Thu Feb 18, 2010 9:11 pm

Hi again,

I have a line of code where I have long SQL string and I'd like to make a line break within the string because of the better legibility of the code.

The code looks like this one:

Code: Select all

put "SELECT thisColumn, thatColumn,  THERE SHOULD BE THE LINE BREAK
"FROM tblTable" into tList
I have tried a backslash but it did not work.

Has anyone an idea?

Thanks

Jörg

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: How can I make a line break within a string in code

Post by bn » Thu Feb 18, 2010 9:23 pm

Joerg,

Code: Select all

put "SELECT thisColumn,thatColumn," & \ -- here is the linebreak, it is a backslash
          "FROM tblTable" into tList
be careful in quoted strings, you have to go about it like in the example, in unquoted revtalk you can say

Code: Select all

 put tSomeThing into \
                 anotherThing
after the backslash you make your return
regards
Bernd

Joerg
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 21
Joined: Sun Dec 20, 2009 12:35 am

Re: How can I make a line break within a string in code

Post by Joerg » Thu Feb 18, 2010 9:37 pm

Hi Bernd,

thank you very much for the quick and competent answer!!!! You made my evening!!!

best regards

Jörg

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: How can I make a line break within a string in code

Post by jalz » Thu Sep 26, 2013 9:23 pm

Hi Guys,
With some research, looks like you use the &\ to break lines down. I seem to have broken it down

Code: Select all

put "CREATE TEMPORARY TABLE tmp AS SELECT customerID, title, first_name, last_name, position, telephone, mobile, email FROM customer_contact WHERE customerID=" & var_customerID & ";" &\
   "UPDATE tmp SET customerID=" & new_customer_id & ";" &\
   "INSERT INTO customer_contact(customerID, title, first_name, last_name, position, telephone, mobile, email) SELECT * FROM tmp;" &\
   "DROP TABLE tmp;" into tTheSQLQuery1
   
   revExecuteSQL gConnID, tTheSQLQuery1

Post Reply