Page 1 of 1
rolling onto a new line in the IDE
Posted: Wed Feb 27, 2013 12:46 am
by Nakia
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>
Re: rolling onto a new line in the IDE
Posted: Wed Feb 27, 2013 1:05 am
by Simon
Not completely sure about the request, but if you are talking about inside the script editor the "\" is use for a new line.
Simon
Re: rolling onto a new line in the IDE
Posted: Wed Feb 27, 2013 1:52 am
by Nakia
Simon,
That is it....
Re: rolling onto a new line in the IDE
Posted: Wed Feb 27, 2013 2:53 am
by Nakia
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
Re: rolling onto a new line in the IDE
Posted: Wed Feb 27, 2013 3:04 am
by Simon
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
Re: rolling onto a new line in the IDE
Posted: Wed Feb 27, 2013 3:10 am
by Nakia
Thanks Simon.
Less than ideal but I will give it a go..
Re: rolling onto a new line in the IDE
Posted: Wed Feb 27, 2013 3:40 am
by Nakia
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=""e&integer"e&">3</project_id>" &cr& "<task_id type=""e&integer"e&">14</task_id>"&cr&"<spent_at type=""e&date"e&">Tue, 17 Oct 2006</spent_at>"&cr&"</request>" into tData
Re: rolling onto a new line in the IDE
Posted: Wed Feb 27, 2013 4:01 am
by Simon
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.
Re: rolling onto a new line in the IDE
Posted: Wed Feb 27, 2013 4:23 am
by Nakia
That did the trick....
Thanks Kindly..
Re: rolling onto a new line in the IDE
Posted: Wed Feb 27, 2013 4:54 am
by Simon
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".
Simon
Re: rolling onto a new line in the IDE
Posted: Wed Feb 27, 2013 5:25 am
by Nakia
Awesome............