Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
a = "PETER~SMITH~DAVIDLU~"
b = "DAVIDLU~"
?ALLTRIM(b)$ a &&This returns TRUE
a = "PETER~SMITH~DAVIDLU~"
b = "DAVID" &&I wrote this as "DAVIDLU"
?ALLTRIM(b)$ a
? ('~'+b) $ a
? ('~'+b) $ ('~'+a)
lnAt = 0
? "Inefficiency?", is_found_in("inefficiency", "efficiency", @lnAt), lnAt
? "Efficiency?", is_found_in("efficiency", "inefficiency", @lnAt), lnAt
? "Happiness?", is_found_in("happiness", "unhappiness", @lnAt), lnAt
* Call with @lnAt as this is a return parameter
FUNCTION is_found_in
LPARAMETERS tcNeedle, tcHaystack, lnAt
IF TYPE("tcNeedle") != "C" OR TYPE("tcHaystack") != "C"
RETURN .F.
ENDIF
* Iterate through the haystack looking for the needle
FOR lnI = 1 TO LEN(tcHaystack) - LEN(tcNeedle) + 1
* Be optimistic, assume we'll find it
llFound = .t.
* Iterate one character by one character to ensure direct comparisonisms
FOR lnJ = 1 TO LEN(tcNeedle)
IF SUBSTR(tcHaystack, lnI + lnJ - 1, 1) != SUBSTR(tcNeedle, lnJ, 1)
* No go. No good. No, sir.
llFound = .f.
EXIT
ENDIF
NEXT
* Was it our happy thing?
IF llFound
* Yes!
lnAt = lnI
RETURN .t.
ENDIF
* Keep going
NEXT
* If we get here, not found
RETURN .f.
a = "PETER~SMITH~DAVIDLU~"
b = "DAVID~" &&Added '~' at the end
?ALLTRIM(b)$ a