Skip to content

CVT

Convert String

This string function edits a string value into a new string value.

CVT (string-value, option-value [,ERR=line-ref|,ERC=error-code])
string-value
is any string.
option-value
is an integer, which designates the editing operations to be performed.
line-ref
is the program line number or label to branch to if an error is produced by this function.
error-code
is a programmer-defined error code. Valid values are positive or negative whole numbers.

Thoroughbred Basic permits option-value to be any integer from .99999999999999E+141 through -2147483649. However, the only significant values range from 0 through 16383 (which is 1+2+4+8+16+32+64+128+256+512+1024+2048+4096+8192).

The CVT function performs editing on string-value based on the bit positions in the binary code value of option-value, but option-value is given in integer format for ease of use.

The following chart lists the option-value, its binary code value, and the editing operation specified by this value. Values are additive; so an option-value of 7 performs the functions of 1, 2, and 4. To avoid confusion you can specify the option-value as the sum of individual values (e.g. 1+2+4) instead of only using the resultant sum (7).

Option
Binary* Operation
0
0000 0000 0000 0000 Do not edit.
1
0000 0000 0000 0001 Clear the high-order (leftmost) bit in each byte.
2
0000 0000 0000 0010 Remove all blanks and tabs.

4 0000 0000 0000 0100 Remove unprintable characters below space

($00$ through $1F$). However, when PRM CVTSTRIP is set, characters from $80$ through $9F$ will also be removed because they are first stripped to $00 through $1F$.

8
0000 0000 0000 1000 Remove all leading spaces and tabs.
16
0000 0000 0001 0000 Reduce each multiple occurrence of spaces and tabs to one each.
32
0000 0000 0010 0000 Convert lowercase characters to uppercase.
64
0000 0000 0100 0000 Convert "[" and "]" to "(" and ")" respectively.
128
0000 0000 1000 0000 Remove all trailing spaces and tabs.
256
0000 0001 0000 0000 Don't alter characters within double quotes.
512
0000 0010 0000 0000 Swap bytes in every 2-byte pair. For example, $01020304$ becomes $02010403$.

1024 0000 0100 0000 0000 Remove all characters that are not spaces,

tabs, alphabetic (upper and lowercase), or

numerics.

2048
0000 1000 0000 0000 Same as option-value=1, but do not alter the field separator for data records (default field separator is usually $8A$).

4096 0001 0000 0000 0000 Convert uppercase characters to lowercase. This has

priority over option-value 32.

8192 0010 0000 0000 0000 Converts the entire string into its mirror

image. For example: “ABCD” becomes
“DCBA”. When combined with other options, this is always performed first.

16384 0100 0000 0000 0000 Replaces all unprintable characters with a space ($00$

- $1F$ and $7F$ - $FF$).

32768
1000 0000 0000 0000 Removes trailing nulls then trailing LF and CRLF
*
Binary values shown for bit positioning only.

Starting with release level 8.9.0, the CVT function options 32, 1024 and 4096 will process foreign characters using #IDSV.LANGUAGE-SUFFIX to determine the language code. If the language code cannot be determined, the CVT function will default to English. The foreign characters processed are the extended ASCII codes based on the Windows-1252 character set. For more information on the extended ASCII codes, please refer to the Thoroughbred Basic Technical Appendices.

LET EDITED_STRING$ = CVT("ALL UPPERCASE WITH EXTRA SPACES ",
8+16+128+4096)

removes leading spaces and tabs (8), removes duplicate spaces and tabs (16), removes trailing spaces and tabs (128), and converts all uppercase characters to lowercase (4096) resulting in EDITED_STRING$ = “all uppercase with extra spaces”.

From the Thoroughbred Basic Language Reference, Volume I: A–E, version 8.9.1. Open this page in the PDF