The short answer is that the best way to break up a long string literal
like this from a single line into multiple lines is to simply
concatenate multiple string literals, like so:
return "This workshop will address the fastest growing and " +
"most requested applications - skin rejuvenation and hair " +
"removal. <br><br><f Name=\"HelveticaNeue MediumExt\">* " +
"Titan<superscript>(r)</superscript> - " +
"<f Name=\"HelveticaNeue LightExt\">Tone and Titan <br>";
Note that this is still a single statement, and that the indentation
here does not affect the returned string literal; it's just for
readability of the code itself. Note also that if you are using a
single statement like this in a statement block (such as an "if"
statement block), then the curly braces { and } are optional, but
including them may improve readability, like so:
if (Field("Objectives")== "Standard")
{
return "This workshop will address the fastest growing and " +
"most requested applications - skin rejuvenation and hair " +
"removal. <br><br><f Name=\"HelveticaNeue MediumExt\">* " +
"Titan<superscript>(r)</superscript> - <f Name=\"HelveticaNeue " +
"LightExt\">Tone and Titan <br>";
}
Now for the longer answer. ;^) The semicolon at the end of a statement
line is optional.* Thus, JavaScript generally treats the end of a line
as the end of a statement, regardless of the presence of a semicolon.
So the following are equivalent:
var s = "hi "
var t = "there"
return s + t
And:
var s = "hi ";
var t = "there";
return s + t;
And even:
var s = "hi "; var t = "there"; return s + t;
Since the semicolon can be used to delimit multiple statements, even on
the same line.
However, if there is no semicolon at the end of a line, the interpreter
will "read ahead" to the next line to determine whether the statement
should be continued. The exact algorithm that the interpreter uses here
is a bit complicated, but generally, it depends on whether the next line
would be valid as a statement in its own right. So the following are
NOT equivalent:
var s = "hi "
"there"
return s
And:
var s = "hi "
+ "there"
return s
In order to avoid any possible ambiguity, I recommend that you include
the semicolon at the end of every statement.
Actually, the fact that line endings can be significant in determining
the end of a statement is the very reason that the Rule Editor dialog,
like almost all other code editors, does NOT auto-wrap: if it did, you
wouldn't know whether each line shown was actually a distinct line, with
its own explicit end-of-line marker (i.e. the "return" key was pressed),
or whether each line was simply part of a longer, auto-wrapped line.
For the sake of completeness, I should also mention that a backslash at
the end of the line is effectively a line-continuation in JavaScript,
even in the middle of a string literal. So you could write your code
like so:
return "This workshop will address the fastest growing and \
most requested applications - skin rejuvenation and hair \
removal. <br><br><f Name=\"HelveticaNeue MediumExt\">* \
Titan<superscript>(r)</superscript> - <f Name=\"HelveticaNeue \
LightExt\">Tone and Titan <br>"
However, I highly discourage this usage, because (for one thing) any
indentation would be included in the literal string. (If you're
returning tags, this may not matter, since the extra spaces would be
removed by the tagged markup parser, but relying on that is not a good
practice.) Such usage can also lead to non-obvious syntax errors if you
modify the code.
So, to sum up, my advice is to use semicolons at the ends of all of your
statements, break up long string literals into multiple string literals,
concatenated with the + operator, and use curly braces ("{" and "}") to
explicitly denote statement blocks.
Dan
* This is because we are not setting the "strict" option for the
interpreter embedded into FusionPro. If we were setting the "strict"
flag, then semicolons would be required, and an error would be generated
if each statement was not terminated with one, even at the end of a
line. However, most implementations of JavaScript are not this strict,
so we felt that it would be simpler for users if we followed the
non-strict convention.
--
Users of FusionPro Desktop have unlimited free email support. Contact Printable
Support at [EMAIL PROTECTED]
--
View FusionPro Knowledge Base, FusionPro Samples at
www.printable.com/vdp/desktop.htm
--
Don't miss The Printable Technologies 2007 User Group Conference at the Monte
Carlo Resort and Casino in Las Vegas, March 14 through March 16, 2007.
For more details or to register, go to
http://www.traveltrust.com/Forms/pt_signup_2007-3.html
--
You are currently subscribed to fusionpro as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
--
--
Note: All e-mail sent to or from this address will be received or otherwise
recorded by the e-mail recipients of this forum. It is subject to archival,
monitoring or review by, and/or disclosure to someone other than the recipient.
Our privacy policy is posted on www.printplanet.com
--