turtlestitch/libraries/make-variables.xml

1 wiersz
2.2 KiB
XML

<blocks app="Snap! 4.2, http://snap.berkeley.edu" version="1"><block-definition s="global variables %&apos;names&apos;" type="command" category="variables"><header></header><code></code><translations></translations><inputs><input type="%mult%txt"></input></inputs><script><block s="doForEach"><l>each item</l><block var="names"/><script><block s="doRun"><block s="reportJSFunction"><list><l>name</l></list><l>if ((typeof name) != "string") {&#xD; throw new Error("name isn&apos;t a string: " + name);&#xD;}&#xD;if (name != "") this.addVariable(name, true);</l></block><list><block var="each item"/></list></block></script></block><block s="doRun"><block s="reportJSFunction"><list></list><l>var ide = this.parentThatIsA(IDE_Morph);&#xD;ide.flushBlocksCache(&apos;variables&apos;); // b/c of inheritance&#xD;ide.refreshPalette();</l></block><list></list></block></script></block-definition><block-definition s="sprite-local variables %&apos;names&apos;" type="command" category="variables"><header></header><code></code><translations></translations><inputs><input type="%mult%txt"></input></inputs><script><block s="doForEach"><l>each item</l><block var="names"/><script><block s="doRun"><block s="reportJSFunction"><list><l>name</l></list><l>if ((typeof name) != "string") {&#xD; throw new Error("name isn&apos;t a string: " + name);&#xD;}&#xD;if (name != "") this.addVariable(name, false);</l></block><list><block var="each item"/></list></block></script></block><block s="doRun"><block s="reportJSFunction"><list></list><l>var ide = this.parentThatIsA(IDE_Morph);&#xD;ide.flushBlocksCache(&apos;variables&apos;); // b/c of inheritance&#xD;ide.refreshPalette();</l></block><list></list></block></script></block-definition><block-definition s="does variable %&apos;var&apos; exist?" type="predicate" category="variables"><header></header><code></code><translations></translations><inputs><input type="%s"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>varname</l></list><l>if ((typeof varname) != "string") {&#xD; throw new Error("name isn&apos;t a string: " + varname);&#xD;}&#xD;return this.isVariableNameInUse(varname, true);</l></block><list><block var="var"/></list></block></block></script></block-definition></blocks>