Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: unterminated string literal error


Message #1 by "Gareth Lock" <gareth.lock@b...> on Fri, 10 Aug 2001 22:40:59
I did not look at the pages themselves, but I found for you an explanation 
that may be a help.

Taken from:
http://www.webfaq.net/cgi-local/webfaq.pl?action=answer&question=c5d3s2q8

*****************Quote number 1*********************
Why do long strings generate the 'Unterminated String Literal' message?
The exact reason why this happens is unclear, but the fix is easy. If the 
following string was causing problems in your code:

var mystr="This is an example of a very long sting that is just like a run-
on sentence and may break the code"
you should break it into smaller peices on sepeareate lines using the + 
sign to concatenate it. The fix would look like this:

var mystr="This is an example of a very long sting"
                    + "that is just like a run-on sentence and may"
          + "break the code.  Somebody suggested theres"
          + "a 254 character limit for Windows 3.1 so"
          + "this example is an attempt to be at least"
          + "that long.  I don't know who would simply"
          + "define a string this long, but there are"
          + "times when it's necessary."
*************End of quote 1******************************

Next are taken from othr places:
*****************Quote 2************
This error message will usually point to the first quote of a string it 
thinks is not terminated. This is a very common error when trying to 
concatenate strings or nest them. You can avoid nesting strings by using a 
pair of \? in-line quote symbols or using a variable to indirectly 
reference a string.

*************Quote 3***************
"Unterminated string literal": Means you probably broke a string across 
two or more lines (using a carriage return) without using a continuation 
backslash at the end of the broken line(s). 
**************End of quote 3**************

  Return to Index