rolling onto a new line in the IDE

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

rolling onto a new line in the IDE

Post by Nakia » Wed Feb 27, 2013 12:46 am

Hi,

I am starting to work with XML and subsequently am needing to build the XML Data which can sometimes be quite a long string.

For example:
If I need to create the below to POST I am doing this in the code below and in the IDE it is a long string so I was wondering can I go to a new line in the IDE?

Code: Select all

put "<notes>Test api support</notes>" &cr&"<hours>3</hours>" &cr"<project_id type="integer">3</project_id>"&cr&"<task_id type="integer">14</task_id>" into tPostData -- etc etc
<request>
<notes>Test api support</notes>
<hours>3</hours>
<project_id type="integer">3</project_id>
<task_id type="integer">14</task_id>
<spent_at type="date">Tue, 17 Oct 2006</spent_at>
</request>

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: rolling onto a new line in the IDE

Post by Simon » Wed Feb 27, 2013 1:05 am

Not completely sure about the request, but if you are talking about inside the script editor the "\" is use for a new line.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: rolling onto a new line in the IDE

Post by Nakia » Wed Feb 27, 2013 1:52 am

Simon,

That is it....

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: rolling onto a new line in the IDE

Post by Nakia » Wed Feb 27, 2013 2:53 am

Simon,

Another question for you...
How do I insert a literal string that has quotes in it?
For example:

<id type="integer">195168</id>

because integer is contained within quotes it causes an error

Code: Select all

put "<id type="integer">195168</id>" into tData -- not accepted by IDE

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: rolling onto a new line in the IDE

Post by Simon » Wed Feb 27, 2013 3:04 am

You have to use "& quote &",
Replace internal " with "& quote &".
Man this is getting tough to actually write it out.
the first " ends the type= string and the second starts the integer string and the word quote is the actual string quote...
ACK!

Code: Select all

 put "<id type="& quote &integer& quote &">195168</id>" into tData
There.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: rolling onto a new line in the IDE

Post by Nakia » Wed Feb 27, 2013 3:10 am

Thanks Simon.

Less than ideal but I will give it a go..

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: rolling onto a new line in the IDE

Post by Nakia » Wed Feb 27, 2013 3:40 am

Hmmm,
Ended up with this but the IDE still does not like it..

Code: Select all

put "<request>" &cr& "<notes> nakia testing API</notes>" &cr& "<project_id type="&quote&integer&quote&">3</project_id>" &cr& "<task_id type="&quote&integer&quote&">14</task_id>"&cr&"<spent_at type="&quote&date&quote&">Tue, 17 Oct 2006</spent_at>"&cr&"</request>" into tData

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: rolling onto a new line in the IDE

Post by Simon » Wed Feb 27, 2013 4:01 am

Sorry I missed a quote:
put "<id type="& quote & "integer" & quote &">195168</id>" into tData
If you have text editor then paste your line in and replace " with " & quote & " then change the first and last quote.

Simon
EDIT: Forget that last line. All wrong.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: rolling onto a new line in the IDE

Post by Nakia » Wed Feb 27, 2013 4:23 am

That did the trick....

Thanks Kindly..

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: rolling onto a new line in the IDE

Post by Simon » Wed Feb 27, 2013 4:54 am

Here Nakia,
Just for you an LC tool.
Copy N Paste your original text e.g.
<notes>Test api support</notes>
<hours>3</hours>
<project_id type="integer">3</project_id>
<task_id type="integer">14</task_id>
<spent_at type="date">Tue, 17 Oct 2006</spent_at>
into the fld and hit the button. The tool prepares the text for "put" - "into".
:D

Simon
Attachments
infamous_quotes.zip
LC 5+
(838 Bytes) Downloaded 223 times
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: rolling onto a new line in the IDE

Post by Nakia » Wed Feb 27, 2013 5:25 am

Awesome............

Post Reply