fun -char !findChar -string &str -char &char set &idx 0 getstrsize $str &len @loop equal $idx $len &store if $store %end getstrcharat $str $idx &stridx equal $stridx $char &store if $store %return add $idx 1 &idx jump %loop @return return $idx @end endfun fun -char !findCharInstance -string &str -char &char -int &instance set &idx 0 getstrsize $str &len @loop equal $idx $len &store if $store %end getstrcharat $str $idx &stridx equal $stridx $char &store if $store %decrement @increment add $idx 1 &idx jump %loop @decrement equal $instance 0 &store if $store %return subtract $instance 1 &instance jump %increment @return return $idx @end endfun fun -string !mid -string &str -int &idx -int &len set &ans "" lesser $idx 0 &store if $store %negend greater $len 0 &store if $store %loop return "" @loop getstrcharat $str $idx &store add $ans $store &ans add $idx 1 &idx getstrsize $ans &store equal $store $len &store if $store %return jump %loop @return return $ans @negend error "Cannot start mid at a negative index" endfun fun -string !inBrackets -string &str -char &left -char &right -int &instance # Get left idx pusharg $str pusharg $left pusharg $instance call !findCharInstance &left # Get right idx pusharg $str pusharg $right pusharg $instance call !findCharInstance &right # Get inner string add $left 1 &left subtract $right $left &store pusharg $str pusharg $left pusharg $store call !mid &store return $store endfun fun -bool !matchStart -string &str -string &instr getstrsize $instr &store pusharg $str pusharg 0 pusharg $store call !mid &store equal $store $instr &store return $store endfun fun -int !findStringInstance -string &str -string &instr -int &instance getstrsize $instr &len subtract $len 1 &len set &idx $len @loop set &tempstr "" subtract $idx $len &tempidx subtract $tempidx 1 &tempidx @subloop equal $tempidx $idx &store if $store %continue add $tempidx 1 &tempidx getstrcharat $str $tempidx &store add $tempstr $store &tempstr jump %subloop @continue equal $tempstr $instr &store if $store %decrement add $idx 1 &idx jump %loop @decrement equal $instance 0 &store if $store %end subtract $instance 1 &instance add $idx 1 &idx jump %loop @end subtract $idx $len &idx return $idx endfun fun -string !removeLeft -string &string -int &num getstrsize $string &len set &ans "" @loop equal $num $len &store if $store %end getstrcharat $string $num &store add $ans $store &ans add $num 1 &num jump %loop @end return $ans endfun fun -string !removeRight -string &string -int &num getstrsize $string &len subtract $len $num &len set &ans "" set &num 0 @loop equal $num $len &store if $store %end getstrcharat $string $num &store add $ans $store &ans add $num 1 &num jump %loop @end return $ans 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 @loop equal $idx $len &store if $store %false pusharg $str pusharg $idx pusharg $inlen call !mid &store equal $store $instr &store if $store %true add $idx 1 &idx jump %loop @true return true @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