strings.bas
来自「smallbasic for linux」· BAS 代码 · 共 53 行
BAS
53 行
' test1.bas' 04/02/2001' GAC - Test string functionality' Print the name of any function that fails to execute as expected.' A clean run will only display the standard '* DONE *'' No way to test these except print them!? "String functions"? date$,time$' Comparisonsif "abc" != "abc" then:? "!=":fiif "abc" <> "abc" then:? "<>":fiif "abc" = "ABC" then:? "=":fiif "a" < "a" then:? "<":fiif "b" <= "a" then:? "<=":fiif "a" > "a" then:? ">":fiif "a" >= "b" then:? ">=":fi' Functions that return int or floatif val("1.2345") <> 1.2345 then:? "val":fiif asc("1.2345") <> 49 then:? "asc":fiif len("1.2345") <> 6 then:? "len":fi' Functions that return a stringif chr$(48) <> "0" then:?"chr$":fiif hex$(18) <> "12" then:? "hex$":fiif oct$(10) <> "12" then:? "oct$":fiif lcase$("ABC") <> "abc" then:? "lcase$":fiif ucase$("abc") <> "ABC" then:? "ucase$":fiif ltrim$(" x ") <> "x " then:? "ltrim$":fiif ltrim$(" ") <> "" then:? "ltrim$ all spaces":fiif rtrim$(" x ") <> " x" then:? "rtrim$":fiif rtrim$(" ") <> "" then:? "rtrim$ all spaces":fiif string$(3,"a") <> "aaa" then:? "string$(s,s)":fiif string$(3,97) <> "aaa" then:? "string$(s,n)":fiif left$("abc",2) <> "ab" then:? "left$":fiif right$("abc",2) <> "bc" then:? "right$":fiif instr("abc","b") <> 2 then:? "instr":fiif mid$("abc",2,1) <> "b" then:? "mid$(s,n,n)":fiif mid$("abc",2) <> "bc" then:? "mid$(s,n)":fiif space$(3) <> " " then:? "space$":fi' Test $ buga="No$"a$="$"if a=a$ then ? "$ bug is alive: variables"if chr(48) <> "0" then ? "$ bug is alive: functions"
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?