Hello. ClaudeB
I guess you’ll have to rename the folders so they start with the new name, this shouldn’t be much of a problem.
My idea was that you “makeCodestring for aSentence” first, then test against all of your other code strings that you have in a list or something, which okCodeStrings kind of demonstrates, using this approach is more laborious for your part, because then you had to iterate over the whole code list, if you had a list containing all the codes that are used, then you could just test if the generated code was in that list.
if there was a “collision” (the handler found the same code), then you call “increaseCodeString for someCode” , and test again, until either no match was found, or Z was reached, (you could add an A when Z is reached, should that ever happen).
I wrote a general handler for returning a number of words in a sentence, it is general, so you’ll have to specify the startword, it is beyond your needs, but it shouldn’t be a problem for using it anyway, as you just specify 1 for the start.
to someWords for aSentence by numWords from startWord
-- we must assume the '&' have been replaced with And
--Assumes we don't pad any missing words with a's
if startWord < 0 then
set startWordTest to -startWord
else
set startWordTest to startWord
end if
tell aSentence
set wc to count words
if ((wc - startWordTest + 1) ≥ numWords and numWords ≥ 1 and (startWordTest ≤ wc and startWordTest ≥ 1)) then
set selectedWords to words startWord thru -1
set selectedWords to items 1 thru numWords of selectedWords
else
set selectedWords to {}
end if
end tell
if selectedWords is {} then
if numWords = 0 or startWord = 0 then
error "someWords: 0 is an illegal value"
else if wc < numWords then
error "someWords: Not enough words in the sentence (range-error), was: " & wc & " needs: " & numWords
else if (wc - startWordTest + 1) < numWords then
error "someWords: numWords out of boundary (range-error), absvalue must be equal or lesser than : number of words in the sentence- abs(startWord) + 1 ( " & (wc - startWordTest + 1) & " ) was: " & numWords
else if (startWordTest > wc) then
error "someWords: startWord out of boundary (range-error), it's absvalue must be equal or lesser than : number of words in the sentence ( " & wc & " ) was: " & startWordTest
end if
else
tell (a reference to my text item delimiters)
set {astid, contents of it} to {contents of it, space}
set sentenceStart to selectedWords as text
set contents of it to astid
end tell
return sentenceStart
end if
end someWords
Before I write something for you that filters foldernames for code, I’d like to know where the folders are stored, if they are stored on your machine locally, or on a server.
Edit
I made the handler above more “sane”, in that numWords now actually denotes the number of words in a sentence, and not the end offset of the words that is to be picked from a sentence.
And:
Fixed the range error tests and error messages!