#

# LogiView

## Function 'strprint'

| 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):
- | (Minus character) If a minus is entered, the converted argument is left-aligned.
Value | (Field width) The converted argument is sent to a field (range) with at least this width or wider, if necessary. If the converted argument contains less characters than required for the field width, the field width is filled up on the left side (or on the right side if left-alignment is specified).
. | (Dot) Separates the field width from the accuracy.
Value | (Accuracy) This value defines the maximum number of characters to be returned from a string expression. This also refers to the number of digits returned after the decimal in a float expression, or the minimum number of digits returned in case of an integer expression.
The following letters are used as conversion characters:
i | Converts an integer expression.
f | Converts a float expression to a float point representation with six digits behind the decimal point, unless an accuracy is specified.
e, E | Converts a float expression to an exponential representation.
g, G | Converts a float expression to the shortest possible type of writing (float point or exponential representation).
s | Converts a string expression.
l | Converts a logic expression to 'TRUE' or 'FALSE'.
% | No conversion; a % is returned.
| 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") S1 = strcat(PATH,"/test.dat") In addition, the following calls have the same meaning: S1 = strprint("%i",3+2^2) S1 = make_str(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:
| {STR_EXPR} | Format character string (string expression).
| {EXPR_LIST} | Arguments to be converted resp. formatted (type corresponding to conversion information).
| - |
| ### Return value:
| {STR_VAR} | Converted string.
| ### 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 "_"!
Command | Output
strprint("%s","LogiView") | "LogiView"
strprint("%5s","LogiView") | "LogiView"
strprint("%.5s","LogiView") | "LogiV"
strprint("%-5s","LogiView") | "LogiView"
strprint("%.12s","LogiView") | "LogiView"
strprint("%-12s","LogiView") | "LogiView_ _ _ _"
strprint("%12.5s","LogiView") | "_ _ _ _ _ _ _LogiV"
strprint("%-12.5s","LogiView") | "LogiV_ _ _ _ _ _ _"
| Functions and commands: Editing Strings