sprintfPL()

Formats a string. Like sprintf(), but change to the current WinCC OA language before converting.

Synopsis

int sprintfPL(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

Formats a string. Like sprintf(), but change to the current WinCC OA language before converting. 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(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
}

The example formats a float variable to a string via the sprintfPL function and reads the value via the sscanfPL function.

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; //sets the value of i to 3.55
  DebugN(i); //i = 3.55
  sprintfPL(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(sscanfPL(s, "%f", i));// Reads the value of s
}

Assignment

Strings

Availability

CTRL