79 lines
2.2 KiB
Plaintext
79 lines
2.2 KiB
Plaintext
|
# checks if the current index in the determiner matches the current index in the target string
|
||
|
fun -bool !currentCharsMatch -string &str -string &determiner -int &counter -int &detIndex
|
||
|
getstrcharat $str $counter ¤tChar
|
||
|
getstrcharat $determiner $detIndex ¤tDetChar
|
||
|
equal $currentChar $currentDetChar &equals
|
||
|
return $equals
|
||
|
endfun
|
||
|
|
||
|
fun -list !split -string &str -string &determiner
|
||
|
# create an empty list
|
||
|
setlist *output ""
|
||
|
set &counter 0
|
||
|
set &detIndex 0
|
||
|
set ¤tLoop "" # basically we build out the current token until we reach the determiner
|
||
|
getstrsize $str &length
|
||
|
getstrsize $determiner &determinerLength
|
||
|
|
||
|
# go through each char in the string, does it match the first char in our determiner?
|
||
|
#@loop
|
||
|
# we are technically getting the current char twice
|
||
|
# 1. inside the currentCharsMatch function
|
||
|
# 2. here
|
||
|
# but oh well, it wont be that bad (i hope)
|
||
|
getstrcharat $str $counter ¤tChar
|
||
|
|
||
|
pusharg $str
|
||
|
pusharg $determiner
|
||
|
pusharg $counter
|
||
|
pusharg $detIndex
|
||
|
call !currentCharsMatch &equals
|
||
|
not $equals &doesntMatch
|
||
|
if $doesntMatch %next
|
||
|
|
||
|
stdlnout "WE HAVE A MATCH"
|
||
|
set &detIndex 0
|
||
|
# WE HAVE A MATCH BABY, we gotta make sure it matches the whole determiner tho
|
||
|
@innerLoop
|
||
|
|
||
|
pusharg $str
|
||
|
pusharg $determiner
|
||
|
pusharg $counter
|
||
|
pusharg $detIndex
|
||
|
call !currentCharsMatch &equals
|
||
|
add $detIndex 1 &detIndex
|
||
|
equal $detIndex $determinerLength &endOfDet
|
||
|
if $endOfDet %append
|
||
|
if $equals %innerLoop
|
||
|
|
||
|
@append
|
||
|
listappend *output $currentLoop
|
||
|
set ¤tLoop ""
|
||
|
set &detIndex 0
|
||
|
|
||
|
@next
|
||
|
add $currentLoop $currentChar ¤tLoop
|
||
|
# next character in the string
|
||
|
add $counter 1 &counter
|
||
|
inequal $length $counter ¬AtEnd
|
||
|
stdlnout $notAtEnd
|
||
|
if $notAtEnd %loop
|
||
|
|
||
|
return *output
|
||
|
endfun
|
||
|
|
||
|
pusharg "split this string"
|
||
|
pusharg " "
|
||
|
call !split *listOut
|
||
|
#getlistsize *listOut &length
|
||
|
#stdlnout $length
|
||
|
|
||
|
set &counter 0
|
||
|
|
||
|
@loopOverList
|
||
|
getlistat *listOut $counter ¤tItem
|
||
|
stdlnout $currentItem
|
||
|
add $counter 1 &counter
|
||
|
getlistsize *listOut &length
|
||
|
inequal $counter $length ¬Done
|
||
|
if $notDone %loopOverList
|