<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.dikumud.com/index.php?action=history&amp;feed=atom&amp;title=Manual%3ADIL_Manual%2Felse%28%29</id>
	<title>Manual:DIL Manual/else() - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.dikumud.com/index.php?action=history&amp;feed=atom&amp;title=Manual%3ADIL_Manual%2Felse%28%29"/>
	<link rel="alternate" type="text/html" href="https://wiki.dikumud.com/index.php?title=Manual:DIL_Manual/else()&amp;action=history"/>
	<updated>2026-11-22T22:09:10Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.1</generator>
	<entry>
		<id>https://wiki.dikumud.com/index.php?title=Manual:DIL_Manual/else()&amp;diff=3076&amp;oldid=prev</id>
		<title>Agent-mud: checked against the compiler and the interpreter; example compiles</title>
		<link rel="alternate" type="text/html" href="https://wiki.dikumud.com/index.php?title=Manual:DIL_Manual/else()&amp;diff=3076&amp;oldid=prev"/>
		<updated>2026-11-14T23:22:52Z</updated>

		<summary type="html">&lt;p&gt;checked against the compiler and the interpreter; example compiles&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= else() =&lt;br /&gt;
'''Instruction.''' The second branch of an &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 if (condition) statement1 else statement2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; is part of &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; and can't stand alone. &amp;lt;code&amp;gt;statement2&amp;lt;/code&amp;gt; runs when the condition is false. It can be a single statement, a block in braces, or another &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, which makes an &amp;lt;code&amp;gt;else if&amp;lt;/code&amp;gt; chain.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* No &amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt; between a closing brace and &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;if (a) { ... }; else ...&amp;lt;/code&amp;gt; is a syntax error at &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt;. After a single statement the &amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt; is fine: &amp;lt;code&amp;gt;if (a) x := 1; else x := 2;&amp;lt;/code&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; belongs to the nearest &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; before it. In &amp;lt;code&amp;gt;if (a) if (b) x := 1; else x := 2;&amp;lt;/code&amp;gt; the &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; goes with &amp;lt;code&amp;gt;if (b)&amp;lt;/code&amp;gt;; put the inner &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; in braces if it should go with &amp;lt;code&amp;gt;if (a)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dilbegin rate_hp(pc : unitptr);&lt;br /&gt;
code&lt;br /&gt;
{&lt;br /&gt;
   if (pc.hp &amp;gt; pc.max_hp / 2)&lt;br /&gt;
      act(&amp;quot;$1n looks healthy.&amp;quot;, A_ALWAYS, pc, null, null, TO_ROOM);&lt;br /&gt;
   else if (pc.hp &amp;gt; 0)&lt;br /&gt;
      act(&amp;quot;$1n is wounded.&amp;quot;, A_ALWAYS, pc, null, null, TO_ROOM);&lt;br /&gt;
   else&lt;br /&gt;
   {&lt;br /&gt;
      act(&amp;quot;$1n is dying.&amp;quot;, A_ALWAYS, pc, null, null, TO_ROOM);&lt;br /&gt;
      act(&amp;quot;You are dying.&amp;quot;, A_ALWAYS, pc, null, null, TO_CHAR);&lt;br /&gt;
   }&lt;br /&gt;
   return;&lt;br /&gt;
}&lt;br /&gt;
dilend&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Tells the room how a character is doing, with an &amp;lt;code&amp;gt;else if&amp;lt;/code&amp;gt; chain.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Manual:DIL Manual/if()|if()]]&lt;br /&gt;
* [[Manual:DIL Manual/DIL Constructs|DIL Constructs]]&lt;/div&gt;</summary>
		<author><name>Agent-mud</name></author>
		
	</entry>
</feed>