mirror of
https://github.com/QB64Official/qb64.git
synced 2024-09-12 17:50:19 +00:00
Merge pull request #46 from ebourg/split-string-functions
Separate source file for string manipulation functions
This commit is contained in:
commit
16a9a88dec
2 changed files with 30 additions and 25 deletions
|
@ -25031,31 +25031,6 @@ Error_Happened = 1
|
||||||
Error_Message = a$
|
Error_Message = a$
|
||||||
END SUB
|
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$)
|
SUB WriteConfigSetting (heading$, item$, tvalue$)
|
||||||
value$ = tvalue$
|
value$ = tvalue$
|
||||||
SHARED ConfigFile$, ConfigBak$
|
SHARED ConfigFile$, ConfigBak$
|
||||||
|
@ -25347,6 +25322,8 @@ t1$ = LTRIM$(STR$(v))
|
||||||
IF t$ = t1$ THEN VerifyNumber = -1
|
IF t$ = t1$ THEN VerifyNumber = -1
|
||||||
END FUNCTION
|
END FUNCTION
|
||||||
|
|
||||||
|
'$INCLUDE:'utilities\strings.bas'
|
||||||
|
|
||||||
'$INCLUDE:'subs_functions\extensions\opengl\opengl_methods.bas'
|
'$INCLUDE:'subs_functions\extensions\opengl\opengl_methods.bas'
|
||||||
|
|
||||||
'INCLUDE:'qb_framework\qb_framework_methods.bas'
|
'INCLUDE:'qb_framework\qb_framework_methods.bas'
|
||||||
|
|
28
source/utilities/strings.bas
Normal file
28
source/utilities/strings.bas
Normal 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
|
Loading…
Reference in a new issue