<div dir="ltr">I awoke this morning with a plan in mind to convert X3DScripts to script code, using new Function. So far, I have just the first few steps.  A big next step is parsing function names.  Comments are welcome. So are contributions to <a href="https://github.com/coderextreme/x3domx3dscripting">https://github.com/coderextreme/x3domx3dscripting</a>.<div>=======================================================</div><div>// Copyright 2020 John W Carlson.  Licensing at link above.</div><div>let scripts = [];<br><br>scripts[0] = new Function (<br><br>// CDATA text follows<br>`ecmascript:<br><br>function initialize() {<br>        console.log("initialize");<br>}<br>function shutdown() {<br>        console.log("shutdown");<br>}<br>// add the following after the CDATA text<br>initialize();</div><div>  // I need to generate this assignment for all the functions in the script. I don't have a good way to parse the function names yet.   <br>this.shutdown = shutdown;<br>return this;`)();<br><br>scripts[0].shutdown();<br></div><div>===============================================================</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 30, 2020 at 9:32 PM John Carlson <<a href="mailto:yottzumm@gmail.com">yottzumm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I am currently thinking about how to handle things like "initialize()".  I know I need at most one for each X3DScript element.  I do not currently have a good way to put these in a separate scope so they don't overwrite each other.  I can create an object to put the script functions in. I do not know if something like new Function() could help with this.  I feel like I'm stumbling in the dark even though I already did this in node/Script.js.  If I could look at the code for ProtoDeclare (where is it?), perhaps it would help?<div><br></div><div>What I'd like to do is enable ROUTEing to/from scripts by using the X3DOM infrastructure.  I do not know how to do this yet, or if it's automatically done for me.</div></div>
</blockquote></div>