Action
eval lines
Does a JS eval on every line of your draft and plops the result at the end of the line.
Some things to try:
5+5 # 10
Math.PI * 2 # 6.283185307179586
var x=8675309
x/3 # 2891769.6666666665
Steps
-
script
function evalLines(text){ var lines = text.split("\n"); var output = ""; for(var i=0;i<lines.length;i++){ var line = lines[i]; if(line.indexOf("#")>-1){ line = line.substring(0,line.indexOf("#")); } var result = ""; try{ result = eval(line); if(result == undefined){ result = ""; } }catch(error){ result = "error"; } output += line; if(result != ""){ output += " # "+result; } output += "\n"; } return output; } draft.content = evalLines(draft.content); draft.update();
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.