Re: Can a function return two values?
Posted: Wed Jun 30, 2021 7:54 pm
Questions and answers about the LiveCode platform.
https://forums.livecode.com/
Code: Select all
put splitSentences(TheText, " who ") into theSplitTextArrayCode: Select all
function splitSentences pText, splitWord
repeat with s = 1 to the number of sentences of ptext
get sentence s of ptext
split it by splitWord
put it into splitText[s]
end repeat
return splitText
end splitSentencesTrue. That makes wordOffset more straightforward. It simply identifies a word in the text string, and that value can be either the end or the beginning of each half.BECAUSE if one uses itemDelimiter the itemDelimiter gets lost.
Code: Select all
return splitWord && splitTextCode: Select all
constant kSubordinatingConjunctions = "after,although,as,as if, as long as,as much as,as soon as,as though,because,before,even if,even though,how,if,in as much as,in case,in order that,in order to,in so far as,insofar as,just as,lest,no matter,now that,once,provided,provided that,rather than,since,so that,than,that,though,till,unless,until,when,whenever,where,whereas,wherever,whether,which,whichever,while,who,whoever,whoever,whomever,whosever,why"
function splitSentences pText
local tSplitText, tText
set the itemdelimiter to comma
replace "(" with space in pText
replace ")" with space in pText
repeat with s = 1 to the number of sentences of pText
put sentence s of ptext into tText
repeat for each item tSplitWord in kSubordinatingConjunctions
if space&tSplitWord&space is in tText then
replace space&tSplitWord&space with cr&tSplitWord&space in tText
end if
end repeat
split tText by cr
put tText into tSplitText[s]
end repeat
breakpoint
return tSplitText
end splitSentencesCode: Select all
constant kSubordinatingConjunctions = "why,whosever,whomever,whoever,whoever,who,while,whichever,which,whether,wherever,whereas,where,whenever,when,until,unless,till,though,that,than,so that,since,rather than,provided that,provided,once,now that,no matter,lest,just as,insofar as,in so far as,in order to,in order that,in case,in as much as,if,how,even though,even if,before,because,as though,as soon as,as much as,as long as,as if,as,although,after"
function splitSentences pText
local tSplitText, tText
set the itemdelimiter to comma
replace "(" with space in pText
replace ")" with space in pText
replace comma with space in pText
repeat with s = 1 to the number of sentences of pText
put sentence s of ptext into tText
repeat for each item tSplitWord in kSubordinatingConjunctions
if space&tSplitWord&space is in tText then
replace space&tSplitWord&space with cr&tSplitWord&numtochar(3) in tText
end if
end repeat
replace numtochar(3) with space in tText
split tText by cr
put tText into tSplitText[s]
end repeat
return tSplitText
end splitSentences- -can't differentiate between subordinating conjunctions and adverbial clauses
Nice!A revision does a better job of things.