Position -1 is the last character of a string

Position 0 is invalid, which matches with STRIN/STRRIN
returning 0 on failure.
This commit is contained in:
Rangi
2021-04-19 12:09:32 -04:00
committed by Eldred Habert
parent dc5b7802c8
commit cf2bbe6435
6 changed files with 29 additions and 26 deletions

View File

@@ -11,7 +11,7 @@ S EQUS "XBold<NULL>ABC"
assert CHARLEN("{S}") == 6
println CHARSUB("{S}", 2)
assert !STRCMP(CHARSUB("{S}", 2), "Bold")
assert CHARSUB("{S}", -4) == CHARSUB("{S}", CHARLEN("{S}") - 4)
assert CHARSUB("{S}", -5) == CHARSUB("{S}", CHARLEN("{S}") + 1 - 5)
assert CHARSUB("{S}", 2) == "Bold" && "Bold" == $88
assert CHARSUB("{S}", 1) == $58 ; ASCII "X"
db "{S}"
@@ -21,7 +21,7 @@ S EQUS "XBold<NULL>ABC"
assert CHARLEN("{S}") == 14
println CHARSUB("{S}", 2)
assert !STRCMP(CHARSUB("{S}", 2), "B")
assert CHARSUB("{S}", -4) == CHARSUB("{S}", CHARLEN("{S}") - 4)
assert CHARSUB("{S}", -5) == CHARSUB("{S}", CHARLEN("{S}") + 1 - 5)
assert CHARSUB("{S}", 2) == "B" && "B" == $42 ; ASCII "B"
assert CHARSUB("{S}", 1) == $58 ; ASCII "X"
db "{S}"