Difference between revisions of "Manual:DIL Manual/tolower()"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
(checked against the compiler and the interpreter; example compiles)
 
Line 1: Line 1:
−
<span id="bftolower"></span>
+
= tolower() =
 +
'''Function''' (string). Returns a string in lower case.
  
 +
tolower(s : string)
  
−
'''Function:''' <i><!--CODE-->string tolower ( s : string );</i><!--ENDCODE-->
+
Returns a copy of <code>s</code> with every capital letter made small:
−
<!--TERM-->  '''s'''
+
<code>tolower("HELLO!")</code> is <code>"hello!"</code>. <code>s</code> itself is not changed.
−
<!--DEFINITION-->         String to lower case
 
−
<!--TERM--> '''return'''
 
−
<!--DEFINITION-->         the string passed in lower cased
 
  
−
This function returns a copy of the string passed in but with out capitals.
+
== Parameters ==
−
  '''Example:''' <i><!--CODE-->"hello!" :=  tolower("HELLO!");</i><!--ENDCODE-->
+
{| class="wikitable"
−
<span id="bftolower"></span>
+
! Name !! Type !! Meaning
 +
|-
 +
| s || string || The string.
 +
|}
  
 +
== Returns ==
 +
String: <code>s</code> in lower case; <code>""</code> for an empty string or one never set.
  
−
'''Function:''' <i><!--CODE-->string tolower ( s : string );</i><!--ENDCODE-->
+
== Notes ==
−
<!--TERM-->   '''s'''
+
* Only the letters A to Z change; letters outside ASCII stay as they are.
−
<!--DEFINITION-->         String to lower case
+
* <code>==</code> on strings already ignores case. Use <code>tolower()</code> where case does
−
<!--TERM--> '''return'''
+
  matter: file names, [[Manual:DIL Manual/getcmd()|getcmd()]],
−
<!--DEFINITION-->         the string passed in lower cased
+
  [[Manual:DIL Manual/replace()|replace()]], <code>&lt;</code> and <code>&gt;</code>.
  
−
This function returns a copy of the string passed in but with out capitals.
+
== Example ==
−
  '''Example:''' <i><!--CODE-->"hello!" :=  tolower("HELLO!");</i><!--ENDCODE-->
+
<pre>
 +
dilbegin got_mail();
 +
var
 +
  ml : unitptr;
 +
code
 +
{
 +
  ml := restore(tolower(self.name), null);
 +
 
 +
  if (ml != null)
 +
  {
 +
      act("<div class='mail'>You have a sudden urge to visit the post office.</div>",
 +
          A_ALWAYS, self, null, null, TO_CHAR);
 +
      destroy(ml);
 +
  }
 +
 
 +
  quit;
 +
}
 +
dilend
 +
</pre>
 +
From mail.zon: at login, checks whether mail was stored for the player under their name in
 +
lower case.
 +
 
 +
== See also ==
 +
* [[Manual:DIL Manual/toupper()|toupper()]]
 +
* [[Manual:DIL Manual/strcmp()|strcmp()]]
 +
* [[Manual:DIL Manual/restore()|restore()]]

Latest revision as of 23:04, 14 November 2026

tolower()

Function (string). Returns a string in lower case.

tolower(s : string)

Returns a copy of s with every capital letter made small: tolower("HELLO!") is "hello!". s itself is not changed.

Parameters

Name Type Meaning
s string The string.

Returns

String: s in lower case; "" for an empty string or one never set.

Notes

  • Only the letters A to Z change; letters outside ASCII stay as they are.
  • == on strings already ignores case. Use tolower() where case does
 matter: file names, getcmd(),
 replace(), < and >.

Example

dilbegin got_mail();
var
   ml : unitptr;
code
{
   ml := restore(tolower(self.name), null);

   if (ml != null)
   {
      act("<div class='mail'>You have a sudden urge to visit the post office.</div>",
          A_ALWAYS, self, null, null, TO_CHAR);
      destroy(ml);
   }

   quit;
}
dilend

From mail.zon: at login, checks whether mail was stored for the player under their name in lower case.

See also