CVT() Function - BBj Specific Information


For this topic's original documentation, see CVT() Function - Pixel, Character, and Semicharacter Unit Conversion.

BBj-Specific Information

The unit conversion values returned for BBj will not necessarily be the same as the values returned for Visual PRO/5. The font used for conversion is the default control font. It may return slightly different values than Visual PRO/5.

Syntax

CVT(string,int{,ERR=lineref})

Description

In BBj 15.0 and higher, the CVT(string,int) function emulates the Thoroughbred Basic CVT function.

Parameter

Description

string

String to be converted.

int

Integer identifying conversion functions, according to the following table.

 

Value

Description

0

Do nothing.

1

Clear the high order bit in each byte, equivalent toAND(string,fill(len(string),$7f$)).

2

Strip out all tabs and spaces.

4

Strip out all $00$ through $1F$ (ASCII control characters below space).

8

Strip out all leading tabs and spaces.

16

Replace multiple spaces with a single space and multiple tabs with a single tab.

32

Convert characters to uppercase.

64

Convert "[" to "(" and "]" to ")".

128

Strip out trailing tabs and spaces.

256

Don't convert characters within double quotes.

512

Swap adjacent bytes, equivalent toSWAP(string,$01$).

1024

Strip out everything but spaces, letters, and numbers.

2048

Same as option 1.

4096

Convert characters to lowercase.

8192

Reverse the entire string.  CVT("Hello world",8192)returns"dlrow olleH".  If specified, this option is always applied first.

16384

Convert nonprintable characters to spaces.

32768

First strip trailing $00$ characters, then strip any trailing $0A$ or $0D0A$ sequences.

ERR=lineref

Branch to be taken if an error occurs during execution.


A combination of operations may be specified by adding functional values. For example, CVT(A$,40) strips leading tabs and spaces and converts to upper case. CVT(A$,40) is equivalent to CVT(A$,32+8), which is equivalent to CVT(CVT(A$,8),32). When multiple operations are combined in a single CVT() function, they are guaranteed to be applied in ascending numeric order (with one exception, 8192, noted above). For example, CVT(CVT(A$,8+16384),16) first strips leading tabs and 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 CVT() in a nested manner as shown in the above example.

Example

0010 LET A$=CVT("    123",8)

0020 PRINT A$

123

See Also

CVS() Function - String Data Conversion

Functions - Alphabetical Listing