rem ' cvt.txt
rem ' https://documentation.basis.cloud/BASISHelp/WebHelp/commands/bbj-commands/cvt_function_bbj_specific_information.htm
print "Running "+pgm(-2)
rem ' 0 = Do not edit.
if cvt("xyzzy",0)<>"xyzzy" then escape
if cvt($000a8a$,0)<>$000a8a$ then escape
rem ' 1 = Clear the high-order (leftmost) bit in each byte.
if cvt($00$,1)<>$00$ then escape
if cvt($8a$,1)<>$0a$ then escape
if cvt($00$,1+256)<>$00$ then escape
if cvt($8a$,1+256)<>$0a$ then escape
if cvt($00$+""""+$ff$+"""",1+256)<>$00$+""""+$ff$+"""" then escape
if cvt($8a$+""""+$ff$+"""",1+256)<>$0a$+""""+$ff$+"""" then escape
rem ' 2 = Remove all blanks and tabs.
if cvt(" This is a test . ",2)<>"Thisisatest." then escape
if cvt($0909$+" This is a test . "+$090900$,2)<>"Thisisatest."+$00$ then escape
if cvt($0909$+" This is a test . "+$090900$,2+256)<>"Thisisatest."+$00$ then escape
if cvt($0909$+" This is a ""quote with spaces"" test . "+$090900$,2+256)<>"Thisisa""quote with spaces""test."+$00$ then escape
rem ' 4 = Remove unprintable characters below space ($00$ through $1F$).
if cvt("Testing"+$000a01$+" 123",4)<>"Testing 123" then escape
if cvt("Testing"+$000a01$+" 123",4+256)<>"Testing 123" then escape
if cvt("Testing"+$000a01$+""""+$0a$+""" 123",4+256)<>"Testing"""+$0a$+""" 123" then escape
cafe! = new String("caf"+$c3a9$,"UTF-8")
if cvt(cafe!,4)<>cafe! then escape
rem ' However, when PRM CVTSTRIP is set, characters from $80$ through $9F$
rem ' will also be removed because they are first stripped to $00 through $1F$.
rem ' 8 = Remove all leading spaces and tabs (option 256 is ignored).
if cvt(" "+$00$+"testing ",8)<>$00$+"testing " then escape
if cvt(" "+$09$+"testing "+$09$,8)<>"testing "+$09$ then escape
rem ' 16 = Reduce each multiple occurrence of spaces and tabs to one each.
if cvt("The quick brown fox",16)<>"The quick brown fox" then escape
if cvt($090909$+"tab"+$090909$+" space ",16)<>$09$+"tab"+$09$+" space " then escape
if cvt("The quick brown fox",16+256)<>"The quick brown fox" then escape
if cvt($090909$+"tab"+$090909$+" space ",16+256)<>$09$+"tab"+$09$+" space " then escape
if cvt("The quick "" "" brown fox",16+256)<>"The quick "" "" brown fox" then escape
if cvt($090909$+"tab"+$090909$+" space """+$090909$+"""",16+256)<>$09$+"tab"+$09$+" space """+$090909$+"""" then escape
rem ' 32 = Convert lowercase characters to uppercase.
if cvt("The quick brown fox",32)<>"THE QUICK BROWN FOX" then escape
if cvt("The quick brown fox",32+256)<>"THE QUICK BROWN FOX" then escape
if cvt("The ""very"" quick brown fox",32+256)<>"THE ""very"" QUICK BROWN FOX" then escape
rem ' 64 = Convert "[" and "]" to "(" and ")" respectively.
if cvt("a[5]",64)<>"a(5)" then escape
if cvt("a(5]",64)<>"a(5)" then escape
if cvt("a[5]",64+256)<>"a(5)" then escape
if cvt("a(5]",64+256)<>"a(5)" then escape
if cvt("a[5]""b[5]""",64+256)<>"a(5)""b[5]""" then escape
if cvt("a(5]""b(5]""",64+256)<>"a(5)""b(5]""" then escape
rem ' 128 = Remove all trailing spaces and tabs (option 256 is ignored).
if cvt($09$+" remove trailing "+$090909$,128)<>$09$+" remove trailing" then escape
rem ' 256 = Don't alter characters within double quotes.
if cvt("xyzzy",256)<>"xyzzy" then escape
if cvt($000a8a$,256)<>$000a8a$ then escape
rem ' 512 = Swap bytes in every 2-byte pair (option 256 is ignored)
rem ' For example, $01020304$ becomes $02010403$.
if cvt($01020304$,512)<>$02010403$ then escape
if cvt($010203$,512)<>$020103$ then escape
if cvt("abcde",512)<>"badce" then escape
if cvt($01020304$,512+256)<>$02010403$ then escape
if cvt($010203$,512+256)<>$020103$ then escape
if cvt("abcde",512+256)<>"badce" then escape
rem ' 1024 = Remove all characters that are not spaces, alphabetic
rem ' (upper and lowercase), or numerics.
rem ' 256 = Don't alter characters within double quotes.
if cvt("!!!only-Alpha_Numeric9"+$0a$+" and spaces",1024)<>"onlyAlphaNumeric9 and spaces" then escape
if cvt("!!!only-Alpha_Numeric9"+$0a$+" and spaces",1024+256)<>"onlyAlphaNumeric9 and spaces" then escape
if cvt("!!!only-Alpha_Numeric9"+"""*"""+$0a$+" and spaces",1024+256)<>"onlyAlphaNumeric9""*"" and spaces" then escape
if CVT("x""a-b""y",1024+256)<>"x""a-b""y" then escape
rem ' 2048 = Same as option-value=1, but do not alter the field separator
rem ' for data records (default field separator is usually $8A$).
rem ' *** Note BBj currently implements CVT(1) and CVT(2048) identically ***
if cvt($00$,2048)<>$00$ then escape
if cvt($8a$,2048)<>$0a$ then escape
if cvt($00$,2048+256)<>$00$ then escape
if cvt($8a$,2048+256)<>$0a$ then escape
if cvt($00$+""""+$ff$+"""",2048+256)<>$00$+""""+$ff$+"""" then escape
if cvt($8a$+""""+$ff$+"""",2048+256)<>$0a$+""""+$ff$+"""" then escape
rem ' 4096 = Convert uppercase characters to lowercase.
rem ' This has priority over option-value 32 (because it's applied later).
if cvt("The quick brown fox",4096)<>"the quick brown fox" then escape
if cvt("The quick brown fox",4096+32)<>"the quick brown fox" then escape
if cvt("The quick brown fox",4096+256)<>"the quick brown fox" then escape
if cvt("The quick brown fox",4096+32+256)<>"the quick brown fox" then escape
if cvt("The ""VERY"" quick brown fox",4096+256)<>"the ""VERY"" quick brown fox" then escape
if cvt("The quick ""LIKE BUNNY"" brown fox",4096+32+256)<>"the quick ""LIKE BUNNY"" brown fox" then escape
rem ' 8192 = Converts the entire string into its mirror image.
rem ' For example: "ABCD" becomes "DCBA".
rem ' When combined with other options, this is always performed first.
if cvt("ABCD",8192)<>"DCBA" then escape
if cvt(" ABCD",8192+128)<>"DCBA" then escape
if cvt("ABCD",8192+256)<>"DCBA" then escape
if cvt(" ABCD",8192+128+256)<>"DCBA" then escape
rem ' 16384 = Replaces all unprintable characters with a space
rem ' ($00$ - $1F$ and $7F$ - $FF$).
if cvt("The"+$00$+"quick"+$8a$+"brown"+$80$+"fox",16384)<>"The quick brown fox" then escape
if cvt("The"+$00$+"quick"+$8a$+"brown"+$80$+"fox",16384+256)<>"The quick brown fox" then escape
if cvt("The"+$00$+"quick"""+$00$+""""+$8a$+"brown"+$80$+"fox",16384+256)<>"The quick"""+$00$+""" brown fox" then escape
rem ' 32768 = Removes trailing nulls then trailing LF and CRLF (option 256 is ignored)
if cvt($00$+"trailing nulls"+$0000$,32768)<>$00$+"trailing nulls" then escape
if cvt($00$+"trailing CRLF"+$0d0a0a0000$,32768)<>$00$+"trailing CRLF" then escape
if cvt(" 123",8)<>"123" then escape
print "Finished ", pgm(-2)
stop
|