width

Prev Next

Function Names

width

Description

This function returns the number of characters in the longest row in the string. If the value provided is not a string, then it will be converted to a string first. If the string contains no new line symbol, then the total number of characters is returned, like in function length [string function].
Attention: For numerals and dates with available string context, the string will be used.

Vectorization: This function supports vectorization in the 1st function parameter. Instead of providing a single value, you can provide a set or even a nested set which contain multiple values. The function will then process every value and its return value contains a corresponding set containing all results.

Call as: function

Restrictions

Indirect parameter passing is disabled
Vectorization is allowed in the 1st function parameter

Parameter count

1

Parameters

No.TypeDescription
1
input
string input string or value

Values not of string type will be converted to strings first. sets will be rejected.

Return value

TypeDescription
numeral
set
Width(s)

Number of characters of longest row. In case of vectorization, the numbers for all strings are provided in a set.

Examples

               text[] = compose( Hello, new line, Everyone, new line, "!!!" );
           echo(text[], new line );
               echo( "Width  = ",  width(text[]), new line, "Length = ", length(text[]) );

Output

Hello
Everyone
!!!

Width  = 8
Length = 18
Try it yourself: Open LIB_Function_width.b4p in B4P_Examples.zip. Decompress before use.

See also

height
length [string function]