Page 1 of 1

Breaking long string in code

Posted: Thursday 25 August 2016 10:46
by tequila
Hi guys,

I cannot figure out how to break a long code line in lua.
I have commandArray['SendEmail'] = 'subject#looong body sring#email'

All working just fine but not very comfortable to edit as it is all in one script line (not the output of the email, but the loa code itself).
How do I berak the code into more lines? Tried several thing but no luck.

I would like to achieve somethig like:

commandArray['SendEmail'] = 'subject#body part 1 /break
.. body part 2 /break
.. body part 3 #email'

to make it more convenient for editing.

Thanks

Re: Breaking long string in code

Posted: Thursday 25 August 2016 13:46
by jmleglise
I don't know bit You may use a variable :

body='some text'
body=body..'some text'
body=body..'some text'
Commandarray...= 'subject#'..body..email

Re: Breaking long string in code

Posted: Thursday 25 August 2016 14:40
by tequila
yeah, the point is that the body itself already contains quite a few variables so I am afraid this would be quite overkill.

Re: RE: Re: Breaking long string in code

Posted: Monday 29 August 2016 22:06
by tequila
jmleglise wrote:I don't know bit You may use a variable :

body='some text'
body=body..'some text'
body=body..'some text'
Commandarray...= 'subject#'..body..email
So in the end this really seems to be the best option. I have not discovered a better way.

Thanks a lot, mate.

Re: Breaking long string in code

Posted: Monday 29 August 2016 22:18
by jvdz
Think you can also shorten it to:

Code: Select all

body = "line1" ..
"line2" ..
"line3" ..
"line4"
print(body)
Jos