<?xml version="1.0" encoding="utf-8"?>
<s1 title="Echo"><table><strong class="highlight"><![CDATA[]]></strong><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Usage: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>echo &quot;Message to be echoed&quot; </p>
</td></tr><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Example: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>echo &quot;Hi,this is a test&quot; </p>
</td></tr></table><p>Allows you to print a message into the log window. This script command replaced the older and less powerful <jump href="/wiki/Print">Print</jump> command, and any new scripts should use this instead. You should also convert your existing scripts to use Echo at your convenience, Print may be deprecated in the future. </p>
<p>Echo is expression friendly. This means that anything you put in quotes will be treated as a plain text string and echoed exactly. Anything you do not put in quotes will be evaluated as an expression.  </p>
<p>For a simple message to the log window: </p>
<p></p>
<source><![CDATA[Script:
echo "This is a line that will show up in the log file"

Results:
19:29:33 This is a line that will show up in the log file
19:29:34 Script stopped]]></source><p>It is also able to display the value of a replacement variable: </p>
<p></p>
<source><![CDATA[Script:
set blurb Testing
echo "%blurb%"

Results:
19:30:10 Testing
19:30:11 Script stopped]]></source><p>Unlike Print, echo is able to display the value of a true variable: </p>
<p></p>
<source><![CDATA[Script:
blurb = "Testing"
echo blurb

Results:
19:31:28 Testing
19:31:29 Script stopped]]></source><p>...  and it is able to evaluate the results of expressions: </p>
<p></p>
<source><![CDATA[math = 1 + 1
echo math
echo 1 + 1

Results:
19:32:22 2
19:32:23 2
19:32:24 Script stopped]]></source><p>If you wanted it to actually print out the text 1 + 1 instead of the result 2, then you would put it in quotes: <em>echo &quot;1 + 1&quot;</em>. </p>
<p>If you wanted to mix variables, objections, plain text, math, whatever in there you can do that.. it might look a little daunting with all the quotes and plus signs, but it&apos;s not too hard when you wrap your head around it. Remember that it will display literally as you write it, so include spaces inside the quotes where you want them: </p>
<p></p>
<source><![CDATA[Script:
echo "My city is located at " + city.coords

Results:
19:35:01 My city is located at 123,456]]></source><p>Note in the above example, I put quotes around the stuff I want it to display word for word, including a space after the word &apos;at&apos;.<br/>
 Then I closed my quotes because the next part (city.coords) is an object I want it to evaluate.<br/>
 The + sign tells it to add the next part to the end of whatever was before. If I didn&apos;t add that it would also add the space after the end quote.<br/>
 Another way to write that could be <em>echo &quot;My city is located at&quot;city.coords</em> but I recommend you get in the habit of seperating them with the + sign. You won&apos;t always be able to jam stuff together like that. </p>
<p>Here&apos;s another example: </p>
<p></p>
<source><![CDATA[Script:
cavs = city.troop.lightCavalry
phracts = city.troop.heavyCavalry
echo "My city at " + city.coords + " has " + (cavs + phracts) "horses in it."

Results:
19:43:34 My city at 123,456 has 69858 horses in it.
19:43:35 Script stopped]]></source><p>In the above example, I used the object city.coords outside of quotes, and I added the values of the variables <em>cavs</em> and <em>phracts</em> together inside the parentheses to display my total number of horses... this math was also outside of quotes since I didn&apos;t want the bot to print the words (cavs + phracts) literally into the log file. I used the + sign to combine all the parts of the echo together. </p>
<p></p>

<br/>------------------------------------------------------------------------------<br/>
<p> <jump href="/wiki/ScriptControlStructures">ScriptControlStructures</jump> </p>
</s1>