Condense libraries, add help texts.

pull/95/head
brianharvey 2020-07-25 21:46:48 -07:00
rodzic 4cd5aa97aa
commit 88a8a5a2f4
12 zmienionych plików z 10 dodań i 17 usunięć

Wyświetl plik

@ -25,17 +25,13 @@ frequency_distribution_module.xml Frequency Distribution Analysis Analyze data f
word-sentence.xml Words, sentences One of the big ideas in Logo that they left out of Scratch is thinking of text as structured into words and sentences, rather than just a string of characters. This library brings back that idea.
strings.xml String processing Extract substrings of a string in various ways
apl.xml APL primitives Adds features from the APL language supporting hyperblocks.
stream-tools.xml Streams (lazy lists) A variation on the list data type in which each list item aren't computed until it's needed, so you can construct million-item lists without really taking up all that time or memory, or even infinite-sized lists. (A block that reports all the prime numbers is included as an example.)
stream-tools.xml Streams (lazy lists) A variation on the list data type in which each list item isn't computed until it's needed, so you can construct million-item lists without really taking up all that time or memory, or even infinite-sized lists. (A block that reports all the prime numbers is included as an example.) See SICP 3.5 for a tutorial.
bar-charts.xml Bar charts Takes a table (typically from a CSV data set) as input and reports a summary of the table grouped by the field in the specified column number. The remaining three inputs are used only if the field values are numbers, in which case they can be grouped into buckets (e.g., decades, centuries, etc.). Those three inputs specify the smallest and largest values of interest and, most importantly, the width of a bucket (10 for decades, 100 for centuries). If the field isn't numeric, leave these three inputs empty or set them to zero. In that case, each string value of the field is its own bucket, and they appear sorted alphabetically. The block reports a new table with three columns. The first column contains the bucket name or smallest number. The second column contains a nonnegative integer that says how many records in the input table fall into this bucket. The third column is a subtable containing the actual records from the original table that fall into the bucket. If your buckets aren't of constant width, or you want to group by some function of more than one field, load the "Frequency Distribution Analysis" library instead.
httpBlocks.xml Web services access (https) An extended version of the URL block that allows POST, PUT, and DELETE as well as GET requests, allows using the secure HTTPS protocol, and gives control over headers, etc. Also parses JSON data.
make-variables.xml Create variables Create and manage global/sprite/script variables in a script
~ ~
~ ~
~ ~
httpBlocks.xml Web services access (https) An extended version of the URL block that allows POST, PUT, and DELETE as well as GET requests, allows using the secure HTTPS protocol, and gives control over headers, etc.
json.xml Deal with JSON data Turn JSON strings into lists with the listify block, then retrieve data out of them by using the value at key block.
~ ~
~ ~
~ ~
HummingbirdBlocks.xml Hummingbird robotics Control the Hummingbird robotics kit processor
leap-library.xml LEAP Motion controller Report hand positions from LEAP Motion controller (leapmotion.com).

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -1 +1 @@
<blocks app="Snap! 5.0, http://snap.berkeley.edu" version="1"><block-definition s="cases: if %&apos;test&apos; then %&apos;result&apos; %&apos;more&apos;" type="command" category="control"><header></header><code></code><translations>pt:se _ , então _ _&#xD;</translations><inputs><input type="%b"></input><input type="%cs"></input><input type="%mult%boolUE"></input></inputs><script><block s="doIfElse"><block var="test"/><script><block s="doRun"><block var="result"/><list></list></block></script><script><custom-block s="catch %upvar %cs"><l>tag</l><script><block s="doForEach"><l>item</l><block var="more"/><script><block s="doIf"><block s="evaluate"><block var="item"/><list></list></block><script><custom-block s="throw %s"><block var="tag"/></custom-block></script></block></script></block></script></custom-block><block s="doHideVar"><l>test</l></block></script></block></script></block-definition><block-definition s="catch %&apos;tag&apos; %&apos;action&apos;" type="command" category="control"><header></header><code></code><translations>pt:captura _ _&#xD;</translations><inputs><input type="%upvar"></input><input type="%cs"></input></inputs><script><block s="doCallCC"><block s="reifyScript"><script><block s="doSetVar"><l>tag</l><block var="cont"/></block><block s="doRun"><block var="action"/><list></list></block></script><list><l>cont</l></list></block></block></script></block-definition><block-definition s="throw %&apos;cont&apos;" type="command" category="control"><header></header><code></code><translations>pt:lança _&#xD;</translations><inputs><input type="%s">catchtag</input></inputs><script><block s="doRun"><block var="cont"/><list></list></block></script></block-definition><block-definition s="else if %&apos;test&apos; then %&apos;action&apos;" type="predicate" category="control"><header></header><code></code><translations>pt:senão, se _ , então _&#xD;</translations><inputs><input type="%b"></input><input type="%cs"></input></inputs><script><block s="doIfElse"><block var="test"/><script><block s="doRun"><block var="action"/><list></list></block><block s="doReport"><block s="reportBoolean"><l><bool>true</bool></l></block></block></script><script><block s="doReport"><block s="reportBoolean"><l><bool>false</bool></l></block></block></script></block></script></block-definition><block-definition s="else %&apos;action&apos;" type="predicate" category="control"><header></header><code></code><translations>pt:senão, _&#xD;</translations><inputs><input type="%cs"></input></inputs><script><block s="doRun"><block var="action"/><list></list></block><block s="doReport"><block s="reportBoolean"><l><bool>true</bool></l></block></block></script></block-definition></blocks>
<blocks app="Snap! 6, https://snap.berkeley.edu" version="1"><block-definition s="cases: if %&apos;test&apos; then %&apos;result&apos; %&apos;more&apos;" type="command" category="control"><comment w="262" collapsed="false">Multi-branched conditional.&#xD;&#xD;If the first (Boolean) input is True, then the script in&#xD;the second (C-slot) input is run, and this block stops.&#xD;&#xD;Additional tests can be added by putting one or more&#xD;ELSE IF blocks in the third (variadic) Boolean slot.&#xD;Use the arrowheads to get the number of Boolean&#xD;slots you need. Each ELSE IF block provides a Boolean&#xD;slot for a condition to test and a script slot for what to do&#xD;if the condition is True. You can put an ELSE block in&#xD;the last Boolean input to CASES for a script to run if&#xD;all the tests turn out False.&#xD;&#xD;As soon as a condition is True, no further tests are done&#xD;and no further scripts are run.</comment><header></header><code></code><translations>pt:se _ , então _ _&#xD;</translations><inputs><input type="%b"></input><input type="%cs"></input><input type="%mult%boolUE"></input></inputs><script><block s="doIfElse"><block var="test"/><script><block s="doRun"><block var="result"/><list></list></block></script><script><custom-block s="catch %upvar %cs"><l>tag</l><script><block s="doForEach"><l>item</l><block var="more"/><script><block s="doIf"><block s="evaluate"><block var="item"/><list></list></block><script><custom-block s="throw %s"><block var="tag"/></custom-block></script></block></script></block></script></custom-block></script></block></script></block-definition><block-definition s="catch %&apos;tag&apos; %&apos;action&apos;" type="command" category="control"><header></header><code></code><translations>pt:captura _ _&#xD;</translations><inputs><input type="%upvar"></input><input type="%cs"></input></inputs><script><block s="doCallCC"><block s="reifyScript"><script><block s="doSetVar"><l>tag</l><block var="cont"/></block><block s="doRun"><block var="action"/><list></list></block></script><list><l>cont</l></list></block></block></script></block-definition><block-definition s="throw %&apos;cont&apos;" type="command" category="control"><header></header><code></code><translations>pt:lança _&#xD;</translations><inputs><input type="%s">catchtag</input></inputs><script><block s="doRun"><block var="cont"/><list></list></block></script></block-definition><block-definition s="else if %&apos;test&apos; then %&apos;action&apos;" type="predicate" category="control"><comment w="176" collapsed="false">For use with the CASES block.&#xD;See its help message.</comment><header></header><code></code><translations>pt:senão, se _ , então _&#xD;</translations><inputs><input type="%b"></input><input type="%cs"></input></inputs><script><block s="doIfElse"><block var="test"/><script><block s="doRun"><block var="action"/><list></list></block><block s="doReport"><block s="reportBoolean"><l><bool>true</bool></l></block></block></script><script><block s="doReport"><block s="reportBoolean"><l><bool>false</bool></l></block></block></script></block></script></block-definition><block-definition s="else %&apos;action&apos;" type="predicate" category="control"><comment w="176" collapsed="false">For use with the CASES block.&#xD;See its help message.</comment><header></header><code></code><translations>pt:senão, _&#xD;</translations><inputs><input type="%cs"></input></inputs><script><block s="doRun"><block var="action"/><list></list></block><block s="doReport"><block s="reportBoolean"><l><bool>true</bool></l></block></block></script></block-definition></blocks>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -1 +0,0 @@
<blocks app="Snap! 5.0, http://snap.berkeley.edu" version="1"><block-definition s="listify %&apos;jsonString&apos;" type="reporter" category="operators"><header></header><code></code><translations>pt:os dados JSON _ em formato de lista&#xD;</translations><inputs><input type="%mlt"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>jsonString</l></list><l>return listify(JSON.parse(jsonString));&#xD;&#xD;function listify(jsonObject) {&#xD; if (jsonObject instanceof Array) {&#xD; return new List(jsonObject.map(function(eachElement) { return listify(eachElement)}));&#xD; } else if (jsonObject instanceof Object) {&#xD; return new List(Object.keys(jsonObject).map(function(eachKey) { return new List([eachKey,listify(jsonObject[eachKey])])} ))&#xD; } else {&#xD; return jsonObject&#xD; }&#xD;}</l></block><list><block var="jsonString"/></list></block></block></script></block-definition><block-definition s="value at key %&apos;key&apos; of %&apos;lst&apos;" type="reporter" category="operators"><header></header><code></code><translations>pt:o valor com chave _ em _&#xD;</translations><inputs><input type="%s"></input><input type="%l"></input></inputs><script><block s="doWarp"><script><block s="doForEach"><l>each item</l><block var="lst"/><script><block s="doIf"><block s="reportEquals"><block s="reportListItem"><l>1</l><block var="each item"/></block><block var="key"/></block><script><block s="doReport"><block s="reportListItem"><l>2</l><block var="each item"/></block></block></script></block></script></block></script></block><block s="doReport"><l></l></block></script></block-definition></blocks>

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -1 +0,0 @@
<blocks app="Snap! 5.0, http://snap.berkeley.edu" version="1"><block-definition s="set pen color to r: %&apos;r&apos; g: %&apos;g&apos; b: %&apos;b&apos;" type="command" category="pen"><header></header><code></code><translations>pt:altera a cor da tua caneta para vermelho _ , verde _ e azul _ (0 a 255)&#xD;</translations><inputs><input type="%n">255</input><input type="%n">0</input><input type="%n">0</input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>r</l><l>g</l><l>b</l></list><l>this.setColor(new Color(r, g, b));</l></block><list><block var="r"/><block var="g"/><block var="b"/></list></block></script></block-definition><block-definition s="set pen color to h: %&apos;h&apos; s: %&apos;s&apos; v: %&apos;v&apos;" type="command" category="pen"><header></header><code></code><translations>pt:altera a cor da caneta para matiz _ , saturação _ e brilho _ (0 a 1)&#xD;</translations><inputs><input type="%n">0.3</input><input type="%n">0.7</input><input type="%n">0.6</input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>h</l><l>s</l><l>v</l></list><l>var col = new Color();&#xD;col.set_hsv(h, s, v);&#xD;this.setColor(col);</l></block><list><block var="h"/><block var="s"/><block var="v"/></list></block></script></block-definition><block-definition s="RGB color" type="reporter" category="pen"><header></header><code></code><translations>pt:a cor da caneta em RGB (vermelho, verde e azul; 0 a 255)&#xD;</translations><inputs></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l></l></list><l>return new List([this.color.r, this.color.g, this.color.b]);</l></block><list></list></block></block></script></block-definition><block-definition s="HSV color" type="reporter" category="pen"><header></header><code></code><translations>pt:a cor da caneta em HSV (matiz, saturação e brilho, 0 a 1)&#xD;</translations><inputs></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l></l></list><l>return new List(this.color.hsv());</l></block><list></list></block></block></script></block-definition></blocks>

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -1 +1 @@
<blocks app="Snap! 5.1, http://snap.berkeley.edu" version="1"><block-definition s="safely try %&apos;action&apos; then if %&apos;error&apos; %&apos;handler&apos;" type="command" category="control"><header></header><code></code><translations>pt:tenta executar _ e, em caso de erro _ , executa _&#xD;</translations><inputs><input type="%cs"></input><input type="%upvar"></input><input type="%cs"></input></inputs><script><custom-block s="let %upvar be %s"><l>reset</l><block s="evaluate"><block s="reportJSFunction"><list><l>proc</l></list><l>var oldHandleError = proc.handleError,&#xD; oldCatchingErrors = proc.isCatchingErrors;&#xD;&#xD;return function(){&#xD; proc.handleError = oldHandleError;&#xD; proc.isCatchingErrors = oldCatchingErrors;&#xD;}</l></block><list></list></block></custom-block><block s="doCallCC"><block s="reifyScript"><script><block s="doRun"><block s="reportJSFunction"><list><l>reset</l><l>action</l><l>handler</l><l>proc</l></list><l>proc.isCatchingErrors = true;&#xD;proc.handleError = function(error, element){&#xD; reset();&#xD; proc.context = handler;&#xD; proc.context.variables.setVar("error", error);&#xD;}&#xD;&#xD;try{&#xD; proc.evaluate(action, new List(), true);&#xD;}&#xD;catch(e){&#xD; proc.handleError(e, null);&#xD;} </l></block><list><block var="reset"/><block var="action"/><block s="reifyScript"><script><block s="doRun"><block s="reifyScript"><script><block s="doRun"><block var="handler"/><list></list></block><block s="doRun"><block var="return"/><list></list></block></script><list></list></block><list></list></block></script><list></list></block></list></block></script><list><l>return</l></list></block></block><block s="doRun"><block var="reset"/><list></list></block></script></block-definition><block-definition s="error %&apos;msg&apos;" type="command" category="control"><header></header><code></code><translations>pt:lança o erro _&#xD;</translations><inputs><input type="%txt"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>msg</l></list><l>throw new Error(msg);</l></block><list><block var="msg"/></list></block></script></block-definition><block-definition s="let %&apos;var&apos; be %&apos;val&apos;" type="command" category="other"><header></header><code></code><translations>pt:cria a variável de guião _ com valor _&#xD;</translations><inputs><input type="%upvar"></input><input type="%s"></input></inputs><script><block s="doSetVar"><l>var</l><block var="val"/></block></script></block-definition><block-definition s="safely try reporting %&apos;this&apos; then if %&apos;error&apos; report %&apos;that&apos;" type="reporter" category="control"><header></header><code></code><translations></translations><inputs><input type="%anyUE"></input><input type="%upvar"></input><input type="%anyUE"></input></inputs><script><block s="doDeclareVariables"><list><l>value</l></list></block><custom-block s="safely try %cs then if %upvar %cs"><script><block s="doSetVar"><l>value</l><block s="evaluate"><block var="this"/><list></list></block></block></script><l>err</l><script><block s="doSetVar"><l>error</l><block var="err"/></block><block s="doSetVar"><l>value</l><block s="evaluate"><block var="that"/><list></list></block></block></script></custom-block><block s="doReport"><block var="value"/></block></script></block-definition></blocks>
<blocks app="Snap! 6, https://snap.berkeley.edu" version="1"><block-definition s="safely try %&apos;action&apos; then if %&apos;error&apos; %&apos;handler&apos;" type="command" category="control"><comment w="276" collapsed="false">Catch errors.&#xD;&#xD;Runs the first script. If it succeeds, nothing else happens.&#xD;But if it has an error (something that would otherwise result&#xD;in a red halo around the block), then the second script is run,&#xD;with the text of the error message that would have been shown in the variable ERROR.</comment><header></header><code></code><translations>pt:tenta executar _ e, em caso de erro _ , executa _&#xD;</translations><inputs><input type="%cs"></input><input type="%upvar"></input><input type="%cs"></input></inputs><script><custom-block s="let %upvar be %s"><l>reset</l><block s="evaluate"><block s="reportJSFunction"><list><l>proc</l></list><l>var oldHandleError = proc.handleError,&#xD; oldCatchingErrors = proc.isCatchingErrors;&#xD;&#xD;return function(){&#xD; proc.handleError = oldHandleError;&#xD; proc.isCatchingErrors = oldCatchingErrors;&#xD;}</l></block><list></list></block></custom-block><block s="doCallCC"><block s="reifyScript"><script><block s="doRun"><block s="reportJSFunction"><list><l>reset</l><l>action</l><l>handler</l><l>proc</l></list><l>proc.isCatchingErrors = true;&#xD;proc.handleError = function(error, element){&#xD; reset();&#xD; proc.context = handler;&#xD; proc.context.variables.setVar("error", error);&#xD;}&#xD;&#xD;try{&#xD; proc.evaluate(action, new List(), true);&#xD;}&#xD;catch(e){&#xD; proc.handleError(e, null);&#xD;} </l></block><list><block var="reset"/><block var="action"/><block s="reifyScript"><script><block s="doRun"><block s="reifyScript"><script><block s="doRun"><block var="handler"/><list></list></block><block s="doRun"><block var="return"/><list></list></block></script><list></list></block><list></list></block></script><list></list></block></list></block></script><list><l>return</l></list></block></block><block s="doRun"><block var="reset"/><list></list></block></script></block-definition><block-definition s="error %&apos;msg&apos;" type="command" category="control"><comment w="268.6666666666667" collapsed="false">Throw an error.&#xD;&#xD;Makes a red halo appear around the script that runs it,&#xD;with the input text shown in a speech balloon next to&#xD;the script, just like any Snap! error.&#xD;&#xD;This is useful to put in the second script of SAFELY TRY&#xD;after some other instructions to undo the partial work of&#xD;the first script.</comment><header></header><code></code><translations>pt:lança o erro _&#xD;</translations><inputs><input type="%txt"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>msg</l></list><l>throw new Error(msg);</l></block><list><block var="msg"/></list></block></script></block-definition><block-definition s="let %&apos;var&apos; be %&apos;val&apos;" type="command" category="other"><comment w="183.33333333333334" collapsed="false">LET (FOO) BE (5)&#xD;is equivalent to&#xD;SCRIPT VARIABLES (FOO)&#xD;SET (FOO) TO (5)</comment><header></header><code></code><translations>pt:cria a variável de guião _ com valor _&#xD;</translations><inputs><input type="%upvar"></input><input type="%s"></input></inputs><script><block s="doSetVar"><l>var</l><block var="val"/></block></script></block-definition><block-definition s="safely try reporting %&apos;this&apos; then if %&apos;error&apos; report %&apos;that&apos;" type="reporter" category="control"><comment w="316.6666666666667" collapsed="false">Catch errors in a reporter.&#xD;&#xD;Evaluates its first input. If that expression successfully reports a value, this block reports that value. If the expression causes a Snap! error,&#xD;then the final input slot is evaluated with the text of what would have&#xD;been the error message in variable ERROR. SAFELY TRY then reports the value of that final expression.&#xD;&#xD;Sometimes you&apos;ll want to throw an error in the final expression. You&#xD;can put an ERROR block inside a CALL block to do that.</comment><header></header><code></code><translations></translations><inputs><input type="%anyUE"></input><input type="%upvar"></input><input type="%anyUE"></input></inputs><script><block s="doDeclareVariables"><list><l>value</l></list></block><custom-block s="safely try %cs then if %upvar %cs"><script><block s="doSetVar"><l>value</l><block s="evaluate"><block var="this"/><list></list></block></block></script><l>err</l><script><block s="doSetVar"><l>error</l><block var="err"/></block><block s="doSetVar"><l>value</l><block s="evaluate"><block var="that"/><list></list></block></block></script></custom-block><block s="doReport"><block var="value"/></block></script></block-definition></blocks>