web stats
Can I use multiline strings in Javascript? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 07-25-2008, 07:34 AM
jbartels jbartels is offline
Mirth Guru
 
Join Date: Oct 2006
Posts: 728
jbartels is on a distinguished road
Default Can I use multiline strings in Javascript?

Can I use multiline strings in Javascript?

I'm thinking that it'd be useful in something like long queries in javascript steps. I can close the string and concatenate, but a simple multiline string would be nice. Is it possible?
__________________
Jon Bartels

Zen is hiring!!!!
http://consultzen.com/careers/
Talented healthcare IT professionals wanted. Engineers to sales to management.
Good benefits, great working environment, genuinely interesting work.
Reply With Quote
  #2  
Old 07-25-2008, 08:12 AM
jbartels jbartels is offline
Mirth Guru
 
Join Date: Oct 2006
Posts: 728
jbartels is on a distinguished road
Default Re:Can I use multiline strings in Javascript?

Google found this trick that works in E4X compatible interpreters. I stuffed this into a filter just to test it.

Code:
var string = (<r><![CDATA[

     The text string goes here.  Since this is a XML CDATA section,
     stuff like <> work fine too, even if definitely invalid XML.

  ]]></r>«»).toString();

logger.error(string);
It works. So now your queries can look nice and neat in javascript steps. HOORAY!

Post edited by: jbartels, at: 07/25/2008 08:14
__________________
Jon Bartels

Zen is hiring!!!!
http://consultzen.com/careers/
Talented healthcare IT professionals wanted. Engineers to sales to management.
Good benefits, great working environment, genuinely interesting work.
Reply With Quote
  #3  
Old 12-29-2008, 02:10 PM
fscudieri@partners.org fscudieri@partners.org is offline
What's HL7?
 
Join Date: Nov 2008
Posts: 1
fscudieri@partners.org
Default Re:Can I use multiline strings in Javascript?

I am trying to execute the following query and I am getting "Wrapped java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0" and "Wrapped java.sql.SQLException: Invalid cursor position" errors. The sql is correct but the concatenation might be invalid. Is there another option for using multiple lines in a sql clause within javascript for Mirth?


Code:
var dbConn = DatabaseConnectionFactory.createDatabaseConnection('net.sourceforge.jtds.jdbc.Driver', 'jdbc:jtds:«»sqlserver://127.0.0.1:2608/dtd_test', 'admin', 'admin');
var string = (<r><![CDATA[
var result = dbConn.executeCachedQuery(SELECT Ins.PolicyNumber as policynumber, 
Ins.RelationToInsured as relationtoinsured, Ins.Record_Count as record_count, 
Insco.InsCompany_Id as inscompany_id, Insco.InsCompany_Name as inscompany_name,
Insadd.InsCompany_Line1 as inscompany_line1, Insadd.InsCompany_Line2 as inscompany_line2,
Insadd.InsCompany_City as inscompany_city, Insadd.InsCompany_State as inscompany_state,
Insadd.InsCompany_Zip as inscompany_zip, Insadd.InsCompany_Country as inscompany_country,
Rec.Record_ID as record_id
from Record Rec
left outer join Insurance Ins on REC.Record_ID = Ins.Record_ID
left outer join InsCompany Insco on REC.Record_ID = Insco.Record_ID
left outer join InsCompany_Address Insadd on REC.Record_ID = Insadd.Record_ID 
where Ins.Record_Count = Insco.Record_Count
and Ins.Record_Count = Insadd.Record_Count);
]]></r>«»).toString();
jbartels - edited to add code tags

Post edited by: jbartels, at: 12/29/2008 14:16
Reply With Quote
  #4  
Old 12-29-2008, 02:18 PM
jbartels jbartels is offline
Mirth Guru
 
Join Date: Oct 2006
Posts: 728
jbartels is on a distinguished road
Default Re:Can I use multiline strings in Javascript?

fscudieri@partners.org wrote:
Quote:
I am trying to execute the following query and I am getting "Wrapped java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0" and "Wrapped java.sql.SQLException: Invalid cursor position" errors. The sql is correct but the concatenation might be invalid. Is there another option for using multiple lines in a sql clause within javascript for Mirth?
Erk. I hope my edit to add code tags to your post didn't mess up the formatting, but it looks like you mixed it up a little bit. You only need the CDATA around the query, not around the script to actually run the query.

Code:
var dbConn = DatabaseConnectionFactory.createDatabaseConnection('net.sourceforge.jtds.jdbc.Driver', 'jdbc:jtds:«»sqlserver://127.0.0.1:2608/dtd_test', 'admin', 'admin');

var string = (<r><![CDATA[
SELECT Ins.PolicyNumber as policynumber, 
Ins.RelationToInsured as relationtoinsured, Ins.Record_Count as record_count, 
Insco.InsCompany_Id as inscompany_id, Insco.InsCompany_Name as inscompany_name,
Insadd.InsCompany_Line1 as inscompany_line1, Insadd.InsCompany_Line2 as inscompany_line2,
Insadd.InsCompany_City as inscompany_city, Insadd.InsCompany_State as inscompany_state,
Insadd.InsCompany_Zip as inscompany_zip, Insadd.InsCompany_Country as inscompany_country,
Rec.Record_ID as record_id
from Record Rec
left outer join Insurance Ins on REC.Record_ID = Ins.Record_ID
left outer join InsCompany Insco on REC.Record_ID = Insco.Record_ID
left outer join InsCompany_Address Insadd on REC.Record_ID = Insadd.Record_ID 
where Ins.Record_Count = Insco.Record_Count
and Ins.Record_Count = Insadd.Record_Count
]]></r>.toString();

var result = dbConn.executeCachedQuery(string);
Post edited by: jbartels, at: 12/29/2008 14:19
__________________
Jon Bartels

Zen is hiring!!!!
http://consultzen.com/careers/
Talented healthcare IT professionals wanted. Engineers to sales to management.
Good benefits, great working environment, genuinely interesting work.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sample Code Template - Strings wseay Development 4 03-26-2013 04:14 AM
Javascript reader: returning a list of strings awohlsch Support 2 01-27-2009 01:39 PM
Receiving strings via TCP connections ricber General Discussion 8 09-13-2007 10:51 AM
Sending strings via TCP connection ricber General Discussion 6 09-03-2007 04:21 PM


All times are GMT -8. The time now is 07:32 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation