I’ve got a draft (code name Fragmence) with hundreds of lines structured like this:
Quote Blah blah blah #tag#tag2
Writing Prompt #tag2
What resources can they bring to bear? #question
My script is trying to pull a random line out. But I’m getting the word “undefined” in my append action at the bottom.
var fullFragDraft = Draft.find('51E1E4D4-F56E-415A-808F-C76E8091B71F')
var splitFrag = fullFragDraft.lines
// this is whete I'd like to filter lines based on words inside i.e. include lines with the text "#Modern" and exclude any lines witn the text "#question"
var filteredFrag = splitFrag
var numLines = filteredFrag.length
var RandLine = Math.round(Math.random() * numLines)
var ResultLine = splitFrag [RandLine]
draft.append ("\n\n" + RandLine + "\n" + filteredFrag.length + "\n" + ResultLine + "\n");
Output:
undefined
1529
2290
What resources can they bring to bear? #question
Explicitly specifying the separator parameter works as I’d expect. The docs actually seem to reference the defaults as being new lines, which must be what is showing as undefined here.