|
This function returns a string created by converting and formatting of the forwarding arguments under the control of a format character string. The first argument of this function is the format character string (a string expression). It contains normal characters copied to the output and conversion information that call the conversion and output of the following expression into the result string. Every conversion information starts with the % character and ends with a conversion character. The space between % and the conversion character may contain the following information (in sequence):
The following letters are used as conversion characters:
|
||||||||||||||||||||||
If the conversion characters do not correspond to the type of the appropriate argument or if the number of information items does not correspond to the number of arguments, the function is aborted and an error message is displayed. | |||||||||||||||||||||||
![]() |
The capabilities of this function partly overlap with other LogiView functions. The following calls have the same meaning: S1 = strprint("%s%s",PATH,"/test.dat") In addition, the following calls have the same meaning: S1 = strprint("%i",3+2^2) In general, the 'strprint' function can be used in various ways; however, compared to "specialized" functions the response times might be longer. In principle, this function could be compared with the 'sprintf' function of the C programming language. |
||||||||||||||||||||||
Syntax: |
|||||||||||||||||||||||
{STR_VAR}= strprint({STR_EXPR},{EXPR_LIST}) | |||||||||||||||||||||||
I/O parameters:
|
|||||||||||||||||||||||
Return value: |
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Example 1: |
|||||||||||||||||||||||
Declaration of Variables | |||||||||||||||||||||||
70 DOCU_STRING_1= strprint("Sinus(%i) is %.3f", DOCU_INT_1,sin(DOCU_INT_1)) |
|||||||||||||||||||||||
Result: (DOCU_INT_1 = 30) | |||||||||||||||||||||||
The string variable DOCU_STRING_1 is assigned with "Sinus(30) is -0.988". | |||||||||||||||||||||||
Example 2: |
|||||||||||||||||||||||
Declaration of Variables | |||||||||||||||||||||||
70 DOCU_STRING_1= strprint("Portion is %f %%",F1*100) |
|||||||||||||||||||||||
Result: (DOCU_FLOAT_1 = 0.454) | |||||||||||||||||||||||
The string variable DOCU_STRING_1 is assigned with "Portion is 45.400000 %". | |||||||||||||||||||||||
Example 3: |
|||||||||||||||||||||||
Declaration of Variables | |||||||||||||||||||||||
The additional examples demonstrate different possibilities to return a formatted string ("LogiView", 10 characters long) by using the appropriate conversion characters (left-aligned, with minimum field width and maximum number of characters): Spaces are represented by "_"!
|
|||||||||||||||||||||||
![]() |
Functions and commands: Editing Strings |