// Test many of the functions in the library. include 'lib' string s = "/usr/local/apache/htdocs/index.html"; print(s); print("String is " + s.size + " characters long."); print("There are " + lib.countChars(s, '/') + " '/' in string."); print("There are " + lib.countSpacedWords(s) + " spaced words in string"); print("There are " + lib.countWords(s) + " words & punctuation in string"); prin("Split into spaced words thats:\n "); print(lib.splitSpaced(s)); prin("Split into words thats:\n "); print(lib.splitWords(s)); print("The first 's' is at position " + lib.findFirstUseOfChar(s, 's')); print("The last '/' is at " + lib.findLastUseOfChar(s, '/')); (string dir, name, extension) = lib.splitPath(s); print("The dir is " + dir); print("The name is " + name); print("The extension is " + extension); dyString dy = s; lib.subChar(dy, '/', '\\'); print("In MS-DOS that's: " + dy); lib.subChar(dy, '\\', '/'); print("Back in Unix that's: " + dy); print("Does prefix start with pre? " + lib.startsWith("pre", "prefix")); print("Does prefix start with post? " + lib.startsWith("post", "prefix")); print("Does suffix end with fix? " + lib.endsWith("suffix", "fix")); print("Does suffix end with mix? " + lib.endsWith("suffix", "mix")); byte casb = lib.lastChar("space "); print("Last char of 'space ' is (in ascii) " + casb); string testString1 = "test string"; array of string wilds = ("*", "?", "**", "??", "???????????", "*?????", "test*", "best*", "tes*ng", "test*?g", "test*n?", "test**n", "*ing", "???*ing", "t?s? s?r?n?", "test string", "widget", "*est*????", "test******r???", "tes*t strin*g"); for (wild in wilds) testMatch(wild, testString1); to testMatch(string wild, string s) { print("'" + wild + "' matches '" + s + "'? " + lib.wildMatch(wild, s)); } string oopsie = "yabba dabba dabba doo"; array of string subs = ("yabba", "dabba", "abba", "oo", " "); print(oopsie); for (s in subs) testSub(oopsie, s, ""); to testSub(string s, string oldString, string newString) { string r = lib.subString(s, oldString, newString); print(oldString + ": " + r); }