Multi Line Code

Hi All

A simple question. How do i spread one long of code over multiple lines?

hanks

put in line breaks?

He may have been looking for an example. Can you give us one?

if (x == 1 &&
    y == 2 &&
    x == 3)
{
     //code here
}

or even

var x = new Array("abc", 
                  "cde", 
                  "efg")

some times you have a string that’s too long…

var str = "lorem ipsum" +
          " suzy chreamcheese"

or alternatively without concatenating

var str = "this is going to be a really \
long string so I'm going to definitely \
break it up into pieces"

note with that final string method any extra spacing you put in will be represented in the string itself, it’s it’s not quite as pretty as far as good looking code goes.

Long strings can be broken up with a single backslash, notice to not put spaces behind the backslash.

var _sql = "SELECT * \
            FROM company \
            WHERE name LIKE '%blabla%' \
                   AND city = 'New York' \
            ORDER BY name DESC"

:oops:

Single backslashes, of course…double would be a comment. My bad.

Thanks everyone! It really helps with the really long SQL statements.

Again, Thanks