sscanfPL()
Imports a string in formatted form. Like sscanf()
, but
changes to the current WinCC OA language before converting.
Synopsis
int sscanfPL(string s, string format, <type1> &var1 [,<type2>
&var2 ...]);
Parameters
Parameter | Description |
---|---|
s | String to be read |
format | Format to be read |
var1, var2, ... | Target variables |
Errors
missing/incorrect arguments
Description
Imports a string in formatted form. Like sscanf() , but changes to the current WinCC OA language before converting. For more examples and description of the format signs see chapter sprintf().
Example
main()
{
string s;
int i=123;
DebugN(sprintfPL(s, "%d", i));
// Number of the characters output = 3
DebugN(s); // s now contains "123"
i=999;
DebugN(sscanfPL(s, "%d", i)); // Read from s as int
DebugN(i); // Again 123
}
main()
{
string s;
float i= 6.99;
sprintfPL(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; //changes the value of the variable i
DebugN(s);
DebugN(sscanfPL(s, "%f", i));//reads the value of parameter
s
DebugN(i);
/* the value of i = 6.99 since the sscanf reads the value of
parameter s
and saves the value in the parameter i*/
}
The sscanfPL() is used like sprintf(). For more different examples of using sscanfPL(), see chapter sprintf().
Assignment
Strings
Availability
CTRL