## CVS

PURPOSE:
String Conversion
TYPE: STRING
FUNCTION SYNTAX:
CVS(str expr,int{,str expr,str expr})
The int value defines bits that specify the conversion (multiple conversion may be specified):

VALUE | DEFINE | CONVERSION
1 | #cvs_strip_leading | Strip Leading Characters
2 | #cvs_strip_trailing | Strip Trailing Characters
4 | #cvs_to_upper | Convert Lowercase to Uppercase
8 | #cvs_to_lower | Convert Uppercase to Lowercase
16 | #cvs_make_printable | Convert Non-printable to Blank
32 | #cvs_spaces_to_space | Convert Multiple characters to a single character
64 | #cvs_comma_decimal | Replace ',' and '.' with SETOPTS bytes 5 and 6
65536 | #cvs_rev_string | Reverse Bytes of a string
131072 | #cvs_replace_sub | Replace one (sub)string by another

    EXAMPLES:
    	To strip BOTH leading and trailing blanks
    	CVS(STRING$,#cvs_strip_leading+#cvs_strip_trailing)

    0010 REM "Using CVS"
    0020 BEGIN
    0030 LET A$=CVS("    abc",1)
    0040 PRINT "[",A$,"] ",HTA(A$)
    0050 LET A$=CVS("____abc",1,"_")
    0060 PRINT "[",A$,"] ",HTA(A$)
    0070 LET A$=CVS("abc    ",2)
    0080 PRINT "[",A$,"] ",HTA(A$)
    0090 LET A$=CVS("abc____",2,"_")
    0100 PRINT "[",A$,"] ",HTA(A$)
    0110 LET A$=CVS("abc",4)
    0120 PRINT "[",A$,"] ",HTA(A$)
    0130 LET A$=CVS("ABC",8)
    0140 PRINT "[",A$,"] ",HTA(A$)
    0150 LET A$=CVS($0102FF$+"abc",16)
    0160 PRINT "[",A$,"] ",HTA(A$)
    0170 LET A$=CVS("   abc   ",32)
    0180 PRINT "[",A$,"] ",HTA(A$)
    0190 LET O$=OPTS;LET O1$=O$(1,4)+"/#";LET O1$(3,1)=IOR(O1$(3,1),$02$);SETOPTS O1$
    0200 LET A$=CVS("123,456,789.00",64)
    0210 PRINT "[",A$,"] ",HTA(A$)
    0220 SETOPTS O$
    0230 LET A$=CVS("abc",65536)
    0240 PRINT "[",A$,"] ",HTA(A$)
    0250 LET A$=CVS("zzzzabcxxxx",131072,"abc","yyyy")
    0260 PRINT "[",A$,"] ",HTA(A$)
    9999 END

    RUN
    [abc] 616263
    [abc] 616263
    [abc] 616263
    [abc] 616263
    [ABC] 414243
    [abc] 616263
    [   abc] 202020616263
    [ abc ] 2061626320
    [123/456/789#00] 3132332F3435362F373839233030
    [cba] 636261
    [zzzzyyyyxxxx] 7A7A7A7A7979797978787878