More functions, plus a bugfix for mid

This commit is contained in:
2025-09-11 20:00:33 +10:00
parent 98fdadfcd8
commit f54d41f5b6

View File

@@ -71,7 +71,6 @@ fun -string !inBrackets -string &str -char &left -char &right -int &instance
pusharg $left
pusharg $instance
call !findCharInstance &store
stdlnout $store
endfun
fun -bool !matchStart -string &str -string &instr
@@ -156,6 +155,8 @@ endfun
fun -bool !contains -string &str -string &instr
getstrsize $str &len
getstrsize $instr &inlen
greater $inlen $len &store
if $store %false
subtract $len $inlen &len
set &idx 0
@@ -179,4 +180,44 @@ fun -bool !contains -string &str -string &instr
@false
return false
endfun
fun -list !split -string &str -string &splitstr
setlist *list
getstrsize $splitstr &splitlen
@loop
pusharg $str
pusharg $splitstr
call !contains &store
if $store %continue
jump %end
@continue
# Find text before split char
pusharg $str
pusharg $splitstr
pusharg 0
call !findStringInstance &store
# Store amount of characters to remove
add $store $splitlen &store2
# Get split
pusharg $str
pusharg 0
pusharg $store
call !mid &store
listappend *list $store
# Remove first split
pusharg $str
pusharg $store2
call !removeLeft &str
jump %loop
@end
listappend *list $str
return *list
endfun