Manual:DIL Manual/right()
Jump to navigation
Jump to search
right()
Function (string). Returns the last characters of a string.
right(s : string, n : integer)
Returns the last n characters of s:
right("This is Easy", 4) is "Easy".
Parameters
| Name | Type | Meaning |
|---|---|---|
| s | string | The string. |
| n | integer | How many characters to take from the end. |
Returns
String: the last n characters. The whole string when n is its length
or more; "" when n is 0 or less, or s is empty.
Notes
right(s, length(s) - 1)is everything but the first character, and
""for an emptys.
- It counts bytes, so a letter outside ASCII (UTF-8) counts as two or more.
Example
dilbegin string say_verb(s : string);
code
{
if (right(s, 1) == "?")
return("ask");
if (right(s, 1) == "!")
return("exclaim");
return("say");
}
dilend
Picks the verb for something said from its last character, as comm.zon does.