Action
On each line
Steps
-
script
//*** WHAT CAN BE DONE STARTS HERE *** //Create a function to do something with each line //This one displays a message containing the text of the line let myFunction1 = strMsg => { alert(strMsg); } //Create another function to do something with each line //This one displays a message containing the character count of the line let myFunction2 = strInput => { alert(strInput.length); } //This next function defines a function called "perLine" which when passed the name of another function (e.g. myFunction1 or myFunction2 above), it will run that function with the line as input. let perLine = (whichFunction) => { //Split the draft into lines and operate on each line let doSomething = draft.content.split("\n").map(strLine => { //This is where what we want to happen gets called eval(whichFunction + "(\"" + strLine + "\")"); }) } //*** WHAT CAN BE DONE ENDS HERE *** //*** FROM HERE ON WE'LL SAY WHAT WE WANT TO DO *** //Let's say hello, then run a function on every line, then say we're going again, run another //function on every line and then finally say we're done. alert("Hello. Let's run the first function on every line.."); perLine("myFunction1"); alert("I think that should have worked. Let's try something else on every line..."); perLine("myFunction2"); alert("That's all I'm planning to do. Goodbye!"); //*** THE END ***
Options
-
After Success Default Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.