|
|
||||
![]() | ||||
In order to prevent the Document Interface from interpreting certain characters
contained in strings as special sequences, it is necessary to "escape" them
by preceding them with a \.
For instance, if you have the string "$foo", you are invoking
a reference to the variable
foo. If you actually wanted to display a $, though,
you would have to use "\$foo". The \ means "don't
give any special meaning to the $." Actually, another way around
this is to use '$foo', which will also prevent foo
from being interpreted as the name of a variable. You will probably find that
there are cases where one method or the other is easier to use.
To include a quote within a set of the same quotes, you should escape it as
well. Another case that must be preceded by \ is the @
character, when used as part of an .IF,
.ELSIF,
.SET,
or .ECHO
command. Actually, you can precede any non-alphanumeric character with a \
if you really want to be careful:
<!--.echo "He said, \"Hey, dude!\""--> (Need slashes with embedded quotes) <!--.echo 'He said, "Hey, dude!"'--> (No slashes needed, since outer quotes are different) <!--.echo "dwilga@mtholyoke.edu"--> (Produces a syntax error message) <!--.echo "dwilga\@mtholyoke.edu"--> (Correct) <!--.echo "dwilga\@mtholyoke\.edu"--> (Correct too!) <!--.echo 'dwilga@mtholyoke.edu'--> (Also works, but can't include variables)
These expressions can also be used in strings:
Sequence
Result
\\Two \'s next to each other become a single\.\nNewline. Not very useful since newlines are ignored in HTML. You probably want <P>or<BR>instead.\NNNASCII character in octal. For example \101for"A".\xNNASCII character in hexadecimal. For example, \x41for"A".\L ... \ELowercase the rest of the string, or until \E. For example,"a\LbCDeF"produces"abcdef". Useful in string comparisons.\U ... \EUppercase the rest of the string, or until \E. For example,"a\UbCDeF"produces"aBCDEF". Useful in string comparisons.\lLowercase the next letter of the string. For example, "a\lBCDeF"produces"abCDeF".\uUppercase the next letter of the string. For example, "a\ubcdef"produces"aBcdef".\S ... \EOmit any extra spaces in the rest of the string, or until \E. Does not alter text within HTML tags. For example,"\S <h3 align=center> TITLE </h3>"produces "<h3 align=center>TITLE</h3>". Useful because some browsers display certain tags differently if there are spaces before or after them.
Home | Directories | Web Email | Calendar | Campus Map | Search | Help
About the College |
Admission |
Academics |
Student Life |
Athletics Copyright © 2002 Mount Holyoke College. This page created by the OIS Operations Group and maintained by Webmaster. Last modified on February 11, 2002. |