<?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%2Fcode</id>
	<title>Manual:DIL Manual/code - 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%2Fcode"/>
	<link rel="alternate" type="text/html" href="https://wiki.dikumud.com/index.php?title=Manual:DIL_Manual/code&amp;action=history"/>
	<updated>2026-11-22T19:15:57Z</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/code&amp;diff=3121&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/code&amp;diff=3121&amp;oldid=prev"/>
		<updated>2026-11-14T23:26:57Z</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;= code =&lt;br /&gt;
'''Keyword.''' Starts the statements of a template.&lt;br /&gt;
&lt;br /&gt;
 code&lt;br /&gt;
 {&lt;br /&gt;
    statements&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Every template has a &amp;lt;code&amp;gt;code&amp;lt;/code&amp;gt; section, after &amp;lt;code&amp;gt;var&amp;lt;/code&amp;gt; and before &amp;lt;code&amp;gt;dilend&amp;lt;/code&amp;gt;. The statements go inside one pair of braces. Labels for &amp;lt;code&amp;gt;goto&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;secure&amp;lt;/code&amp;gt; are written &amp;lt;code&amp;gt;:name:&amp;lt;/code&amp;gt; on a line of their own.&lt;br /&gt;
&lt;br /&gt;
A program copied onto a unit starts at the first statement, and stops at &amp;lt;code&amp;gt;quit&amp;lt;/code&amp;gt;. A called procedure or function goes back to its caller at &amp;lt;code&amp;gt;return&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* The braces must hold at least one statement: an empty &amp;lt;code&amp;gt;{ }&amp;lt;/code&amp;gt; is a syntax error.&lt;br /&gt;
* vmc ends the code with a jump back to the first statement. A program that reaches the closing brace starts over from the top, with its variables as they were. That is a way to write a loop, but a program that never waits ends up stopped by the server as &amp;quot;had endless loop&amp;quot;.&lt;br /&gt;
* A called template that reaches the closing brace also starts over instead of returning to its caller. End procedures with &amp;lt;code&amp;gt;return;&amp;lt;/code&amp;gt; and functions with &amp;lt;code&amp;gt;return(value);&amp;lt;/code&amp;gt; on every path.&lt;br /&gt;
* Statements are separated by semicolons; a block &amp;lt;code&amp;gt;{ ... }&amp;lt;/code&amp;gt; groups statements for &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt; and the like.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dilbegin chimes();&lt;br /&gt;
var&lt;br /&gt;
   n : integer;&lt;br /&gt;
code&lt;br /&gt;
{&lt;br /&gt;
   heartbeat := PULSE_SEC * 30;&lt;br /&gt;
   pause;&lt;br /&gt;
   n := n + 1;&lt;br /&gt;
   if (n &amp;gt; 3)&lt;br /&gt;
   {&lt;br /&gt;
      act(&amp;quot;The chimes fall silent.&amp;quot;, A_ALWAYS, self, null, null, TO_ALL);&lt;br /&gt;
      quit;&lt;br /&gt;
   }&lt;br /&gt;
   act(&amp;quot;The chimes ring &amp;quot; + itoa(n) + &amp;quot; times.&amp;quot;, A_ALWAYS, self, null, null, TO_ALL);&lt;br /&gt;
}&lt;br /&gt;
dilend&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On an object (&amp;lt;code&amp;gt;dilcopy chimes@ex();&amp;lt;/code&amp;gt; in its definition): every 30 seconds it rings, running from the top again each time it reaches the closing brace, and stops after the third time.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Manual:DIL Manual/dilbegin|dilbegin]]&lt;br /&gt;
* [[Manual:DIL Manual/var|var]]&lt;br /&gt;
* [[Manual:DIL Manual/dilend|dilend]]&lt;br /&gt;
* [[Manual:DIL Manual/quit|quit]]&lt;br /&gt;
* [[Manual:DIL Manual/return()|return()]]&lt;br /&gt;
* [[Manual:DIL Manual/goto|goto]]&lt;/div&gt;</summary>
		<author><name>Agent-mud</name></author>
		
	</entry>
</feed>