CVS() Function
BBj-Specific Information
For this topic's original documentation, see the CVS() Function.
Syntax
CVS(string,int{,chars}{,ERR=lineref})
Description
The CVS() function modifies a given string by the value of int from the table below:
Parameter | Description |
---|---|
string | String to be converted. |
int | Integer identifying conversion functions, according to the following table. |
chars |
In BBj 19.00 and higher, this is an optional value that can be used to modify any CVS function that normally manipulates spaces (1, 2, 16, 32, 128). If specified, the first character of the string is used instead of the usual space. For example, the following strips trailing $00$ characters: CVS($0000$+"XYZZY"+$0000$,2,$00$) In BBj 19.10 and higher, CVS functions 1, 2, and 128 accept multiple characters in this parameter. |
ERR=lineref | Branch to be taken if an error occurs during execution. |
Values for int Parameter
Value | Description |
---|---|
0 | Do nothing. |
1 | Strip leading spaces (*) (**). |
2 | Strip trailing spaces (*) (**). |
4 | Convert characters to uppercase. |
8 | Convert characters to lowercase. |
16 | Convert non-printable characters to spaces (*). |
32 | Replace multiple spaces with a single space (*). |
64 | Replace "," and "." characters with values as specified in OPTS (see SETOPTS). |
128 | Strip all spaces (*) (**). |
(*) If the optional char parameter was specified, use it instead of space.
(**) In BBj 19.10 and higher, the optional chars parameter can specify multiple characters.
A combination of operations may be specified by adding functional values. For example, CVS(A$,5) strips leading spaces and converts to upper case. CVS(A$,5) is equivalent to CVS(A$,1+4), which is equivalent to CVS(CVS(A$,1),4). When multiple operations are combined in a single CVS() function, they are guaranteed to be applied in ascending numeric order. For example, CVS(A$,1+16+32) first strips leading spaces, then converts non-printable characters to spaces, and finally replaces multiple spaces with a single space. To apply multiple options in a different order, execute the CVS() in a nested manner as shown in the above example.
By default, the BBj CVS() function, like the original PRO/5 version, refers to the !CTYPE string to determine character types. If the JAVA_CVS !COMPATsetting is set to TRUE, BBj uses internal Java functions to determine if characters are uppercase, lowercase, digits, whitespace, or punctuation.
Version History
-
BBj 19.10 - CVS functions 1, 2, and 128 accept multiple characters in the char parameter.
Examples
0010 LET A$=CVS(" 123",1)
0020 PRINT A$
123