Code: Select all
' Examples from StrFind in ZBasicSysLib.pdf v 2.2.5
Sub main()
Dim idx as Byte
idx = StrFind("haystack", "needle") ' returns 0
Debug.Print "expected: 0, returns: " ; CStr(idx)
idx = StrFind("haystack with needle", "needle") ' returns 15
Debug.Print "expected: 15, returns: " ; CStr(idx)
idx = StrFind("foo bar foo", "foo", 2) ' returns 9
Debug.Print "expected: 9, returns: " ; CStr(idx)
idx = StrFind("foo bar foo", "", 2) ' returns 2
Debug.Print "expected: 2, returns: " ; CStr(idx)
idx = StrFind("foo bar FOO", "FOO") ' returns 9
Debug.Print "expected: 9, returns: " ; CStr(idx)
idx = StrFind("foo bar FOO", "FOO", 1, true) ' returns 1
Debug.Print "expected: 1, returns: " ; CStr(idx)
End Sub
Code: Select all
ZX1280 v2.6.3 00df,6c6a
Downloading file "C:zbasiclibstest.zxb":
...................
Download complete.
Verifying download:
...................
Verification complete.
expected: 0, returns: 0
expected: 15, returns: 0
expected: 9, returns: 0
expected: 2, returns: 1
expected: 9, returns: 0
expected: 1, returns: 1