1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-07-03 07:41:21 +00:00

Makes strings.bas $includable by option _explicit projects

This commit is contained in:
Fellippe Heitor 2021-03-10 17:22:37 -03:00
parent 64ea6d64ca
commit 532ade2d8e

View file

@ -1,28 +1,33 @@
' '
' String manipulation functions ' String manipulation functions
' '
FUNCTION StrRemove$ (myString$, whatToRemove$) 'noncase sensitive FUNCTION StrRemove$ (myString$, whatToRemove$) 'noncase sensitive
a$ = myString$ DIM a$, b$
b$ = LCASE$(whatToRemove$) DIM AS LONG i
i = INSTR(LCASE$(a$), b$)
DO WHILE i a$ = myString$
a$ = LEFT$(a$, i - 1) + RIGHT$(a$, LEN(a$) - i - LEN(b$) + 1) b$ = LCASE$(whatToRemove$)
i = INSTR(LCASE$(a$), b$) i = INSTR(LCASE$(a$), b$)
LOOP DO WHILE i
StrRemove$ = a$ a$ = LEFT$(a$, i - 1) + RIGHT$(a$, LEN(a$) - i - LEN(b$) + 1)
END FUNCTION i = INSTR(LCASE$(a$), b$)
LOOP
FUNCTION StrReplace$ (myString$, find$, replaceWith$) 'noncase sensitive StrRemove$ = a$
IF LEN(myString$) = 0 THEN EXIT FUNCTION END FUNCTION
a$ = myString$
b$ = LCASE$(find$) FUNCTION StrReplace$ (myString$, find$, replaceWith$) 'noncase sensitive
basei = 1 DIM a$, b$
i = INSTR(basei, LCASE$(a$), b$) DIM AS LONG basei, i
DO WHILE i IF LEN(myString$) = 0 THEN EXIT FUNCTION
a$ = LEFT$(a$, i - 1) + replaceWith$ + RIGHT$(a$, LEN(a$) - i - LEN(b$) + 1) a$ = myString$
basei = i + LEN(replaceWith$) b$ = LCASE$(find$)
i = INSTR(basei, LCASE$(a$), b$) basei = 1
LOOP i = INSTR(basei, LCASE$(a$), b$)
StrReplace$ = a$ DO WHILE i
END FUNCTION a$ = LEFT$(a$, i - 1) + replaceWith$ + RIGHT$(a$, LEN(a$) - i - LEN(b$) + 1)
basei = i + LEN(replaceWith$)
i = INSTR(basei, LCASE$(a$), b$)
LOOP
StrReplace$ = a$
END FUNCTION