1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-02 03:50:36 +00:00

Merge pull request #46 from ebourg/split-string-functions

Separate source file for string manipulation functions
This commit is contained in:
Fellippe Heitor 2018-06-17 21:21:42 -03:00 committed by GitHub
commit 16a9a88dec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 25 deletions

View file

@ -25031,31 +25031,6 @@ Error_Happened = 1
Error_Message = a$
END SUB
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
SUB WriteConfigSetting (heading$, item$, tvalue$)
value$ = tvalue$
SHARED ConfigFile$, ConfigBak$
@ -25347,6 +25322,8 @@ t1$ = LTRIM$(STR$(v))
IF t$ = t1$ THEN VerifyNumber = -1
END FUNCTION
'$INCLUDE:'utilities\strings.bas'
'$INCLUDE:'subs_functions\extensions\opengl\opengl_methods.bas'
'INCLUDE:'qb_framework\qb_framework_methods.bas'

View file

@ -0,0 +1,28 @@
'
' 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