# Explode String Splitter # by Martin del Rio # https://www.ldpl-lang.org/ # Created for LDPL 1.0 DATA: explode/words is text vector explode/index is number explode/string is text explode/length is number explode/stringlength is number explode/current-token is text explode/char is text explode/separator is text i is number PROCEDURE: # Ask for a sentence display "Enter a sentence: " accept explode/string # Declare explode Subprocedure # Splits a text into a text vector by a certain delimiter # Input parameters: # - explode/string: the string to explode (destroyed) # - explode/separator: the character used to separate the string (preserved) # Output parameters: # - explode/words: vector of splitted words # - explode/length: length of explode/words sub-procedure explode join explode/string and explode/separator in explode/string get length of explode/string in explode/stringlength store 0 in explode/index store 0 in explode/length store "" in explode/current-token while explode/index is less than explode/stringlength do get character at explode/index from explode/string in explode/char if explode/char is equal to explode/separator then store explode/current-token in explode/words:explode/length in explode/length solve explode/length + 1 store "" in explode/current-token else join explode/current-token and explode/char in explode/current-token end if in explode/index solve explode/index + 1 repeat in explode/length solve explode/length - 1 end sub-procedure # Separate the entered string store " " in explode/separator call sub-procedure explode while i is less than or equal to explode/length do display explode/words:i crlf in i solve i + 1 repeat