sprintfUL()
The function formats a string like sprintf()
but changes
to the current user language before formatting.
Synopsis
int sprintfUL(string s, string format [,<type1> var1 [,<type2>
var2 ...]]);
Parameters
Parameter | Description |
---|---|
s | string |
format | Format |
var1, var2, ... | Values |
Return value
see Description below
Error
missing/incorrect arguments
Description
The function formats a string like sprintf() but changes to the current user language before formatting so that language dependent elements of format signs such as time data is formatted based on the set language. The change of the user language only applies to the respective process (meaning to the function sprintfUL) and not to the whole Windows language. For more examples and description of the format signs see chaptersprintf().
Example
Writes the value of the int variable i to string variable s.
main()
{
string s;
int i=123;
DebugN(sprintfUL(s, "%d", i)); // Number of the characters
output = 3
DebugN(s); // s now contains 123
i=999;
DebugN(sscanfUL(s, "%d", i)); // Read from s as int
DebugN(i); // Again 123
}
The example formats a float variable to a string via the sprintfUL function and reads the value via the sscanfUL function.
main()
{
string s;
float i= 6.99;
sprintfUL(s, "%5.3f\n", i); //Writes the value of float
parameter i to the string parameter s (formats a float to a
string).
DebugN(s); //s = 6.99
i=3.55; //sets the value of i to 3.55
DebugN(i); //i = 3.55
sprintfUL(s, "%5.3f\n", i);//writes the new value of parameter i
to parameter s (formats a float to a string)
DebugN(s); //s = 3.55
DebugN(sscanfUL(s, "%f", i));// Reads the value of s
}
Assignment
Strings
Availability
CTRL