1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-07-01 09:10:37 +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
'
FUNCTION StrRemove$ (myString$, whatToRemove$) 'noncase sensitive
a$ = myString$
b$ = LCASE$(whatToRemove$)
i = INSTR(LCASE$(a$), b$)
DO WHILE i
a$ = LEFT$(a$, i - 1) + RIGHT$(a$, LEN(a$) - i - LEN(b$) + 1)
i = INSTR(LCASE$(a$), b$)
LOOP
StrRemove$ = a$
END FUNCTION
FUNCTION StrReplace$ (myString$, find$, replaceWith$) 'noncase sensitive
IF LEN(myString$) = 0 THEN EXIT FUNCTION
a$ = myString$
b$ = LCASE$(find$)
basei = 1
i = INSTR(basei, LCASE$(a$), b$)
DO WHILE i
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
'
' String manipulation functions
'
FUNCTION StrRemove$ (myString$, whatToRemove$) 'noncase sensitive
DIM a$, b$
DIM AS LONG i
a$ = myString$
b$ = LCASE$(whatToRemove$)
i = INSTR(LCASE$(a$), b$)
DO WHILE i
a$ = LEFT$(a$, i - 1) + RIGHT$(a$, LEN(a$) - i - LEN(b$) + 1)
i = INSTR(LCASE$(a$), b$)
LOOP
StrRemove$ = a$
END FUNCTION
FUNCTION StrReplace$ (myString$, find$, replaceWith$) 'noncase sensitive
DIM a$, b$
DIM AS LONG basei, i
IF LEN(myString$) = 0 THEN EXIT FUNCTION
a$ = myString$
b$ = LCASE$(find$)
basei = 1
i = INSTR(basei, LCASE$(a$), b$)
DO WHILE i
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