valstr
Description:
Function valstr convert an integer into a string.
This function name starts with a lowercase letter. |
Passing a high value to this function can cause the server to freeze/crash. Fixes are available. Below is a fix that can be put straight in to your script (before valstr is used anywhere). fixes.inc includes this fix. |
Parameters:
(dest[], value, bool:pack = false)
string | dest | The destination of the string. |
int | value | The value to convert to a string. |
bool | pack | Whether to pack the destination (off by default). |
Return Values:
This function does not return any specific values.
Examples:
new string[4]; new iValue = 250; valstr(string,iValue); // string is now "250"
// valstr fix by Slice stock FIX_valstr(dest[], value, bool:pack = false) { // format can't handle cellmin properly static const cellmin_value[] = !"-2147483648"; if (value == cellmin) pack && strpack(dest, cellmin_value, 12) || strunpack(dest, cellmin_value, 12); else format(dest, 12, "%d", value), pack && strpack(dest, dest, 12); } #define valstr FIX_valstr
Related Functions
The following functions may be useful, as they are related to this function in one way or another.
- strlen: Get the length of a string.
- strpack: Pack a string. Packed strings use 75% less memory.
- strunpack: Unpack a string.
- strcat: Concatenates (joins together) two strings into the destination string.
- strmid: Extract a range of characters from a string.
- strins: Insert a string into another string.
- strdel: Delete part of a string.
- strcmp: Compares two strings to see if they are the same.
- strfind: Search for a sub string in a string.
- strval: Convert a string to an integer.
- ispacked: Checks if the given string is packed.
- uudecode: Decode an UU-encoded string.
- uuencode: Encode a string to an UU-decoded string.
- memcpy: Copy bytes from one location to another.