Manual:DIL Manual/itoa()
Jump to navigation
Jump to search
itoa()
Function (string). An integer written as text.
itoa(i : integer) : string
Turns a number into its decimal text, with a minus sign when it is negative, so it can be joined to other strings with +. DIL doesn't turn numbers into text by itself: "You have " + self.hp doesn't compile.
Parameters
| Name | Type | Meaning |
|---|---|---|
| i | integer | The number. |
Returns
The text: itoa(42) is "42", itoa(-7) is "-7". When i fails (for example a field of a null unit), the call fails too and a string variable assigned from it is emptied.
Example
dilbegin show_hp();
code
{
sendtext("You have " + itoa(self.hp) + " of " + itoa(self.max_hp)
+ " hit points.<br/>", self);
quit;
}
dilend
Shows a character its hit points.