<blocks app="Snap! 7, https://snap.berkeley.edu" version="2"><block-definition s="mb messages in %&apos;in&apos; matching %&apos;filter&apos;" type="reporter" category="other" helper="true"><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%s">*</input></inputs><script><block s="doDeclareVariables"><list><l>result</l><l>len</l><l>i</l><l>msgLen</l><l>end</l><l>cmd</l><l>b2</l></list></block><block s="doSetVar"><l>result</l><block s="reportNewList"><list></list></block></block><block s="doSetVar"><l>len</l><block s="reportListAttribute"><l><option>length</option></l><block var="in"/></block></block><block s="doSetVar"><l>i</l><l>1</l></block><block s="doForever"><script><block s="doUntil"><block s="reportOr"><block s="reportGreaterThan"><block var="i"/><block var="len"/></block><block s="reportOr"><block s="reportEquals"><block s="reportListItem"><block var="i"/><block var="in"/></block><l>250</l></block><block s="reportEquals"><block s="reportListItem"><block var="i"/><block var="in"/></block><l>251</l></block></block></block><script><block s="doChangeVar"><l>i</l><l>1</l></block></script></block><block s="doIf"><block s="reportLessThan"><block s="reportDifference"><block var="len"/><block var="i"/></block><l>2</l></block><script><custom-block s="delete before %n of %l"><block var="i"/><block var="in"/></custom-block><block s="doReport"><block var="result"/></block></script></block><block s="doSetVar"><l>cmd</l><block s="reportListItem"><block s="reportVariadicSum"><list><block var="i"/><l>1</l></list></block><block var="in"/></block></block><block s="doIfElse"><block s="reportEquals"><block s="reportListItem"><block var="i"/><block var="in"/></block><l>250</l></block><script><block s="doIf"><block s="reportOr"><block s="reportNot"><block s="reportIsA"><block var="filter"/><l><option>number</option></l></block></block><block s="reportEquals"><block var="cmd"/><block var="filter"/></block></block><script><block s="doAddToList"><block s="reportListItem"><block s="reportNumbers"><block s="reportVariadicSum"><list><block var="i"/><l>1</l></list></block><block s="reportVariadicSum"><list><block var="i"/><l>2</l></list></block></block><block var="in"/></block><block var="result"/></block></script></block><block s="doChangeVar"><l>i</l><l>3</l></block></script><script><block s="doIfElse"><block s="reportAnd"><block s="reportEquals"><block s="reportListItem"><block var="i"/><block var="in"/></block><l>251</l></block><block s="reportGreaterThan"><block s="reportDifference"><block var="len"/><block var="i"/></block><l>3</l></block></block><script><block s="doSetVar"><l>msgLen</l><block s="reportVariadicSum"><list><block s="reportVariadicProduct"><list><l>256</l><block s="reportListItem"><block s="reportVariadicSum"><list><block var="i"/><l>4</l></list></block><block var="in"/></block></list></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="i"/><l>3</l></list></block><block var="in"/></block></list></block></block><block s="doSetVar"><l>end</l><block s="reportVariadicSum"><list><block s="reportVariadicSum"><list><block var="i"/><l>4</l></list></block><block var="msgLen"/></list></block></block><block s="doIf"><block s="reportGreaterThan"><block var="end"/><block var="len"/></block><script><custom-block s="delete before %n of %l"><block var="i"/><block var="in"/></custom-block><block s="doReport"><block var="result"/></block></script></block><block s="doIf"><block s="reportOr"><block s="reportNot"><block s="reportIsA"><block var="filter"/><l><option>number</option></l></block></block><block s="reportEquals"><block var="cmd"/><block var="filter"/></block></block><script><block s="doAddToList"><block s="reportListItem"><block s="reportNumbers"><block s="reportVariadicSum"><list><block var="i"/><l>1</l></list></block><block var="end"/></block><block var="in"/></block><block var="result"/></block></script></block><block s="doSetVar"><l>i</l><block s="reportVariadicSum"><list><block var="end"/><l>1</l></list></block></block></script><script><custom-block s="delete before %n of %l"><block var="i"/><block var="in"/></custom-block><block s="doReport"><block var="result"/></block></script></block></script></block></script></block></script></block-definition><block-definition s="MicroBlocks messages do %&apos;msg&apos; %&apos;cmds&apos;" type="command" category="other"><header></header><code></code><translations></translations><inputs><input type="%upvar"></input><input type="%cs"></input></inputs><script><block s="doDeclareVariables"><list><l>data</l><l>msgType</l><l>len</l></list></block><block s="doSetVar"><l>data</l><custom-block s="WEBSer $flash-1-0-255-0 read %s"><block var="mb_port"/></custom-block></block><block s="doIf"><block s="reportIsA"><block var="data"/><l><option>list</option></l></block><script><block s="doWarp"><script><block s="doSetVar"><l>mb_buffer</l><block s="reportConcatenatedLists"><list><block var="mb_buffer"/><block var="data"/></list></block></block><block s="doForEach"><l>msgBytes</l><custom-block s="mb messages in %s matching %s"><block var="mb_buffer"/><l>27</l></custom-block><script><block s="doSetVar"><l>len</l><block s="reportListAttribute"><l><option>length</option></l><block var="msgBytes"/></block></block><block s="doIf"><block s="reportGreaterThan"><block var="len"/><l>4</l></block><script><block s="doSetVar"><l>msg</l><block s="reportListItem"><block s="reportNumbers"><l>5</l><block var="len"/></block><block var="msgBytes"/></block><comment w="126" collapsed="true">Extract message body</comment></block><block s="doSetVar"><l>msg</l><block s="reportJoinWords"><list><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportUnicodeAsLetter"><l></l></block></autolambda><list></list></block><block var="msg"/></block></list></block><comment w="125" collapsed="true">Convert bytes to text</comment></block><block s="doRun"><block var="cmds"/><list></list><comment w="180" collapsed="true">Run commands with current msg</comment></block></script></block></script><comment w="162" collapsed="true">For each broadcast message:</comment></block></script></block></script><comment w="232.2353515625" collapsed="true">Got some data! Process it...</comment></block></script></block-definition><block-definition s="MicroBlocks send %&apos;aString&apos;" type="command" category="other"><header></header><code></code><translations></translations><inputs><input type="%s"></input></inputs><script><block s="doDeclareVariables"><list><l>len</l><l>bytes</l></list></block><block s="doWarp"><script><block s="doSetVar"><l>len</l><block s="reportVariadicSum"><list><block s="reportStringSize"><block var="aString"/></block><l>1</l></list></block></block><block s="doSetVar"><l>bytes</l><block s="reportNewList"><list><l>251</l><l>27</l><l>0</l><block s="reportModulus"><block var="len"/><l>256</l></block><block s="reportMonadic"><l><option>floor</option></l><block s="reportQuotient"><block var="len"/><l>256</l></block></block></list></block></block><block s="doForEach"><l>i</l><block s="reportNumbers"><l>1</l><block s="reportStringSize"><block var="aString"/></block></block><script><block s="doAddToList"><block s="reportUnicode"><block s="reportLetter"><block var="i"/><block var="aString"/></block></block><block var="bytes"/></block></script></block><block s="doAddToList"><l>254</l><block var="bytes"/></block></script></block><custom-block s="WEBSer $flash-1-0-255-0 write %s %l"><block var="mb_port"/><block var="bytes"/></custom-block></script></block-definition><block-definition s="delete before %&apos;index&apos; of %&apos;list&apos;" type="command" category="lists" helper="true"><header></header><code></code><translations></translations><inputs><input type="%n"></input><input type="%l"></input></inputs><script><block s="doWarp"><script><block s="doRepeat"><block s="reportDifference"><block var="index"/><l>1</l></block><script><block s="doDeleteFromList"><l>1</l><block var="list"/></block></script></block></script></block></script></block-definition><block-definition s="MicroBlocks connect" type="command" category="other"><header></header><code></code><translations></translations><inputs></inputs><script><block s="doIf"><block s="reportNot"><custom-block s="does var %s exist?"><l>mb_port</l></custom-block></block><script><custom-block s="create %s var %mult%txt"><l>global</l><list><l>mb_port</l></list></custom-block><custom-block s="hide var %s"><l>mb_port</l></custom-block></script></block><block s="doIf"><block s="reportNot"><custom-block s="does var %s exist?"><l>mb_buffer</l></custom-block></block><script><custom-block s="create %s var %mult%txt"><l>global</l><list><l>mb_buffer</l></list></custom-block><custom-block s="hide var %s"><l>mb_buffer</l></custom-block></script></block><block s="doSetVar"><l>mb_port</l><custom-block s="WEBSer $flag-1-0-255-0 open %n"><l>115200</l></custom-block></block><block s="doSetVar"><l>mb_buffer</l><block s="reportNewList"><list></list></block></block></script></block-definition><block-definition s="MicroBlocks disconnect" type="command" category="other"><header></header><code></code><translations></translations><inputs></inputs><script><block s="doIf"><block s="reportNot"><block s="reportEquals"><block var="mb_port"/><l>0</l></block></block><script><custom-block s="WEBSer $flag-1-255-0-0 close %s"><block var="mb_port"/></custom-block></script></block><block s="doSetVar"><l>mb_port</l><l>0</l></block><block s="doSetVar"><l>mb_buffer</l><l>0</l></block></script></block-definition><block-definition s="WEBSer $flash-1-0-255-0 write %&apos;port&apos; %&apos;bytes&apos;" type="command" category="other" helper="true"><comment x="0" y="0" w="193.33528645833292" collapsed="true">Write to the port a list containing numbers</comment><header></header><code></code><translations></translations><inputs><input type="%s">port</input><input type="%l"></input></inputs><script><block s="doApplyExtension"><l>srl_write(port, bytes)</l><list><block var="port"/><block var="bytes"/></list></block></script></block-definition><block-definition s="WEBSer $flash-1-0-255-0 read %&apos;port&apos;" type="reporter" category="other" helper="true"><header></header><code></code><translations></translations><inputs><input type="%s">port</input></inputs><script><block s="doReport"><block s="reportApplyExtension"><l>srl_read(port)</l><list><block var="port"/></list></block></block></script></block-definition><block-definition s="WEBSer $flag-1-0-255-0 open %&apos;baudRate&apos;" type="reporter" category="other" helper="true"><header></header><code></code><translations></translations><inputs><input type="%n">115200<options>9600&#xD;19200&#xD;38400&#xD;57600&#xD;115200</options></input></inputs><script><block s="doReport"><block s="reportApplyExtension"><l>srl_open(baud, buffer)</l><list><block var="baudRate"/><l>15000</l></list></block></block></script></block-definition><block-definition s="WEBSer $flag-1-255-0-0 close %&apos;port&apos;" type="command" category="other" helper="true"><comment x="0" y="0" w="90" collapsed="true">Close port.</comment><header></header><code></code><translations></translations><inputs><input type="%s" readonly="true">port</input></inputs><script><block s="doApplyExtension"><l>srl_close(port)</l><list><block var="port"/></list></block></script></block-definition><block-definition s="create %&apos;_scope&apos; var %&apos;_names&apos;" type="command" category="variables" helper="true"><comment x="0" y="0" w="146" collapsed="false">This block creates  new variables on the selected scope: global (for all sprites), sprite (for this sprite only) or script (only for that blocks stack) with the names given (in &apos;names&apos; list).&#xD;&#xD;If there is already a variable with that name in that scope, it does nothing: no errors and no overwrites.</comment><header></header><code></code><translations>pt:cria as variáveis _ _&#xD;ca:crea les _ variables _&#xD;es:crear las _ variables _&#xD;de:erstellen _ var _&#xD;</translations><inputs><input type="%s" readonly="true">global<options>global&#xD;sprite&#xD;script</options></input><input type="%mult%txt"></input></inputs><script><block s="doWarp"><script><block s="doForEach"><l>_item</l><block var="_names"/><script><block s="doApplyExtension"><l>var_declare(scope, name)</l><list><block var="_scope"/><block var="_item"/></list></block></script></block></script></block></script></block-definition><block-definition s="delete var %&apos;_names&apos;" type="command" category="variables" helper="true"><comment x="0" y="0" w="217" collapsed="false">This block deletes all the variables with the names given (inside input list).&#xD;&#xD;Each name will make only one variable deletion, and this will be the variable found following the scope order: &apos;script&apos; -&gt; &apos;sprite&apos; -&gt; &apos;global&apos;.&#xD;&#xD;If we have a &quot;testing&quot; sprite variable and also a &quot;testing&quot; global one, deleting &quot;testing&quot; will delete only the sprite one (Yes! we can also do &quot;delete var (testing, testing)&quot; to delete both.&#xD;&#xD;If one variable does not exists (in any scope) an error happens, stopping block action in that point. You can check it before with the &quot;does var (name) exists?&quot;block. </comment><header></header><code></code><translations>pt:remove as variáveis _&#xD;ca:esborra les variables _&#xD;es:borrar variables _&#xD;de:löschen var _&#xD;</translations><inputs><input type="%mult%txt"></input></inputs><script><block s="doWarp"><script><block s="doForEach"><l>_item</l><block var="_names"/><script><block s="doApplyExtension"><l>err_ignore</l><list><custom-block s="var %s"><block var="_item"/></custom-block></list></block><block s="doApplyExtension"><l>var_delete(name)</l><list><block var="_item"/></list></block></script></block></script></block></script></block-definition><block-definition s="set var %&apos;_name&apos; to %&apos;_value&apos;" type="command" category="variables" helper="true"><comment x="0" y="0" w="240.4931640625" collapsed="false">This block sets the given value (last input) to the variable named with the name givent (var input).&#xD;&#xD;It looks for that variable following the scope order &apos;script&apos; -&gt; &apos;sprite&apos; -&gt; &apos;global&apos; (the first match it finds).&#xD;&#xD;If that variable does not exist (in any scope) an error happens, stopping their script. You can check it before using the &quot;does var (name) exists?&quot; block. </comment><header></header><code></code><translations>ca:assigna a _ el valor _&#xD;es:asignar a _ el valor _&#xD;pt:altera _ para _&#xD;de:setze var _ auf _&#xD;</translations><inputs><input type="%s"><options>§_getVarNamesDict</options></input><input type="%s"></input></inputs><script><block s="doApplyExtension"><l>var_set(name, val)</l><list><block var="_name"/><block var="_value"/></list></block></script></block-definition><block-definition s="var %&apos;_name&apos;" type="reporter" category="variables" helper="true"><comment x="0" y="0" w="178.00000000000003" collapsed="false">This block reports the value of the variable with the name given.&#xD;&#xD;It looks for that variable following the scope order &apos;script&apos; -&gt; &apos;sprite&apos; -&gt; &apos;global&apos; (the first match it finds).&#xD;&#xD;If that variable does not exist (in any scope) an error happens, stopping their script. You can check it before using the &quot;does var (name) exists?&quot; block. </comment><header></header><code></code><translations>pt:o valor de _&#xD;</translations><inputs><input type="%s"><options>§_getVarNamesDict</options></input></inputs><script><block s="doReport"><block s="reportApplyExtension"><l>var_get(name)</l><list><block var="_name"/></list></block></block></script></block-definition><block-definition s="does var %&apos;_name&apos; exist?" type="predicate" category="variables" helper="true"><comment x="0" y="0" w="146" collapsed="false">This block reports &quot;true&quot; if there is a variable with this given name (input slot) in that context.&#xD;&#xD;It can be a global, sprite or script variable.&#xD;&#xD;Otherwise it reports &quot;false&quot;.</comment><header></header><code></code><translations>pt:a variável _ existe&#xD;ca:existeix la variable _ ?&#xD;es:existe la variable _ ?&#xD;de:existiert var _ ?&#xD;</translations><inputs><input type="%s"></input></inputs><script><block s="doApplyExtension"><l>err_try(cmd, catch, err)</l><list><block s="reifyScript"><script><block s="doApplyExtension"><l>err_ignore</l><list><block s="reportApplyExtension"><l>var_get(name)</l><list><block var="_name"/></list></block></list></block><block s="doReport"><block s="reportBoolean"><l><bool>true</bool></l></block></block></script><list></list></block><block s="reifyScript"><script><block s="doReport"><block s="reportBoolean"><l><bool>false</bool></l></block></block></script><list></list></block><l></l></list></block><block s="doApplyExtension"><l>err_reset</l><list></list></block></script></block-definition><block-definition s="show var %&apos;_name&apos;" type="command" category="variables" helper="true"><comment x="0" y="0" w="181" collapsed="false">This block turns on (show) the watcher view on stage (if it was not already activated) of the variable with the given name (slot input).&#xD;&#xD;It can only access to the closest variable scope (if there different variables with the same name in different scopes) following the order &apos;script&apos; -&gt; &apos;sprite&apos; -&gt; &apos;global&apos;.&#xD;&#xD;No errors if that variable does not exist.</comment><header></header><code></code><translations>ca:mostra la variable _&#xD;es:mostrar variable _&#xD;pt:mostra a variável _&#xD;de:zeige var _&#xD;</translations><inputs><input type="%s"><options>§_getVarNamesDict</options></input></inputs><script><block s="doApplyExtension"><l>var_show(name)</l><list><block var="_name"/></list></block></script></block-definition><block-definition s="hide var %&apos;_name&apos;" type="command" category="variables" helper="true"><comment x="0" y="0" w="181" collapsed="false">This block turns off (hide) the watcher view on stage (if it was not already activated) of the variable with the given name (slot input).&#xD;&#xD;It can only access to the closest variable scope (if there different variables with the same name in different scopes) following the order &apos;script&apos; -&gt; &apos;sprite&apos; -&gt; &apos;global&apos;.&#xD;&#xD;No errors if that variable does not exist.</comment><header></header><code></code><translations>ca:amaga la variable _&#xD;es:esconder variable _&#xD;pt:esconde a variável _&#xD;de:verstecke var _&#xD;</translations><inputs><input type="%s"><options>§_getVarNamesDict</options></input></inputs><script><block s="doApplyExtension"><l>var_hide(name)</l><list><block var="_name"/></list></block></script></block-definition></blocks>