<?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%2Fgetcmd%28%29</id>
	<title>Manual:DIL Manual/getcmd() - 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%2Fgetcmd%28%29"/>
	<link rel="alternate" type="text/html" href="https://wiki.dikumud.com/index.php?title=Manual:DIL_Manual/getcmd()&amp;action=history"/>
	<updated>2026-11-22T21:12:08Z</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/getcmd()&amp;diff=2830&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/getcmd()&amp;diff=2830&amp;oldid=prev"/>
		<updated>2026-11-14T23:04:10Z</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;= getcmd() =&lt;br /&gt;
'''Function''' (cmdptr). Finds a command from its name or an abbreviation.&lt;br /&gt;
&lt;br /&gt;
 getcmd(s : string)&lt;br /&gt;
&lt;br /&gt;
Returns the command a player would get by typing &amp;lt;code&amp;gt;s&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;getcmd(&amp;quot;look&amp;quot;)&amp;lt;/code&amp;gt; is&lt;br /&gt;
the look command, &amp;lt;code&amp;gt;getcmd(&amp;quot;n&amp;quot;)&amp;lt;/code&amp;gt; is ''north''. Its fields&lt;br /&gt;
(&amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;level&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;type&amp;lt;/code&amp;gt;, ...) are on the&lt;br /&gt;
[[Manual:DIL Manual/cmdptr|cmdptr]] page.&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Name !! Type !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| s || string || The command, whole or abbreviated, in lower case.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Returns ==&lt;br /&gt;
cmdptr: the command, or null when no command begins with &amp;lt;code&amp;gt;s&amp;lt;/code&amp;gt;. It fails when&lt;br /&gt;
&amp;lt;code&amp;gt;s&amp;lt;/code&amp;gt; is a string variable that was never set.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* An abbreviation gives the command the game picks for it, the same as when a player types it.&lt;br /&gt;
* Case matters: commands are in lower case, so &amp;lt;code&amp;gt;getcmd(&amp;quot;Look&amp;quot;)&amp;lt;/code&amp;gt; is null. Use&lt;br /&gt;
  [[Manual:DIL Manual/tolower()|tolower()]] on what a player typed.&lt;br /&gt;
* &amp;lt;code&amp;gt;getcmd(&amp;quot;&amp;quot;)&amp;lt;/code&amp;gt; is not null: it returns the first command in the list. Test for an&lt;br /&gt;
  empty string first.&lt;br /&gt;
* Socials are in the list too (their &amp;lt;code&amp;gt;type&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;TYPE_SOCIAL&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dilbegin cmd_info(arg : string);&lt;br /&gt;
var&lt;br /&gt;
   cmd : cmdptr;&lt;br /&gt;
code&lt;br /&gt;
{&lt;br /&gt;
   if (arg == &amp;quot;&amp;quot;)&lt;br /&gt;
   {&lt;br /&gt;
      sendtext(&amp;quot;Which command?&amp;lt;br/&amp;gt;&amp;quot;, self);&lt;br /&gt;
      quit;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   cmd := getcmd(tolower(arg));&lt;br /&gt;
   if (cmd == null)&lt;br /&gt;
      sendtext(&amp;quot;No command starts with '&amp;quot; + arg + &amp;quot;'.&amp;lt;br/&amp;gt;&amp;quot;, self);&lt;br /&gt;
   else&lt;br /&gt;
      sendtext(&amp;quot;'&amp;quot; + arg + &amp;quot;' is the command &amp;quot; + cmd.name + &amp;quot;, level &amp;quot; +&lt;br /&gt;
               itoa(cmd.level) + &amp;quot;.&amp;lt;br/&amp;gt;&amp;quot;, self);&lt;br /&gt;
   quit;&lt;br /&gt;
}&lt;br /&gt;
dilend&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
A player command that tells which command a word stands for and its level.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Manual:DIL Manual/cmdptr|cmdptr]]&lt;br /&gt;
* [[Manual:DIL Manual/chead()|chead()]]&lt;br /&gt;
* [[Manual:DIL Manual/command()|command()]]&lt;br /&gt;
* [[Manual:DIL Manual/cmdstr|cmdstr]]&lt;/div&gt;</summary>
		<author><name>Agent-mud</name></author>
		
	</entry>
</feed>