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

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="bftoupper"></span>
+
= toupper() =
 +
'''Function''' (string). Returns a string in upper case.
  
−
  '''Function:'''  <i><!--CODE-->string toupper ( s : string );</i><!--ENDCODE-->
+
  toupper(s : string)
  
−
<!--TERM--> '''s'''
+
Returns a copy of <code>s</code> with every small letter made a capital:
−
<!--DEFINITION-->         String to lower case
+
<code>toupper("hello!")</code> is <code>"HELLO!"</code>. <code>s</code> itself is not changed.
−
<!--TERM--> '''return'''
 
−
<!--DEFINITION-->         the string passed in lower cased
 
  
−
This function returns a copy of the string passed in with all characters changed
+
== Parameters ==
−
to be capitalized.
+
{| class="wikitable"
−
'''Example:'''  <i><!--CODE-->"HELLO!" := toupper ("hello!");</i><!--ENDCODE-->
+
! Name !! Type !! Meaning
 +
|-
 +
| s || string || The string.
 +
|}
  
 +
== Returns ==
 +
String: <code>s</code> in upper case; <code>""</code> for an empty string or one never set.
  
−
---~---~---~---~---~---~---~---~---
+
== Notes ==
−
<span id="bftoupper"></span>
+
* Only the letters a to z change; letters outside ASCII stay as they are.
 +
* To capitalise only the first letter, combine it with [[Manual:DIL Manual/left()|left()]] and
 +
  [[Manual:DIL Manual/right()|right()]] as in the example.
  
−
'''Function:'''  <i><!--CODE-->string toupper ( s : string );</i><!--ENDCODE-->
+
== Example ==
 +
<pre>
 +
dilbegin string capital(s : string);
 +
code
 +
{
 +
  return(toupper(left(s, 1)) + right(s, length(s) - 1));
 +
}
 +
dilend
 +
</pre>
 +
Returns the string with its first letter a capital, as helpzon.zon does with a help topic.
  
−
<!--TERM-->  '''s'''
+
== See also ==
−
<!--DEFINITION-->        String to lower case
+
* [[Manual:DIL Manual/tolower()|tolower()]]
−
<!--TERM-->  '''return'''
+
* [[Manual:DIL Manual/left()|left()]]
−
<!--DEFINITION-->        the string passed in lower cased
+
* [[Manual:DIL Manual/right()|right()]]
−
 
 
−
This function returns a copy of the string passed in with all characters changed
 
−
to be capitalized.
 
−
'''Example:'''  <i><!--CODE-->"HELLO!" := toupper ("hello!");</i><!--ENDCODE-->
 
−
 
 
−
 
 
−
---~---~---~---~---~---~---~---~---
 

Latest revision as of 23:04, 14 November 2026

toupper()

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

toupper(s : string)

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

Parameters

Name Type Meaning
s string The string.

Returns

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

Notes

  • Only the letters a to z change; letters outside ASCII stay as they are.
  • To capitalise only the first letter, combine it with left() and
 right() as in the example.

Example

dilbegin string capital(s : string);
code
{
   return(toupper(left(s, 1)) + right(s, length(s) - 1));
}
dilend

Returns the string with its first letter a capital, as helpzon.zon does with a help topic.

See also