bharvey wrote:
In the tool package (tools.ypr or ToolSprite.ysp in the BYOB folder) there's a block SENTENCE->LIST that does what you want.
Perhaps I am looking at the wrong list blocks, but it is not obvious how to get the string input to convert to separate list items. In other words, if the input sentence is "My name is John", how do I transform this into a list of 4 items:
1 My
2 name
3 is
4 John
rather than a list of 1 item (with the 4 elements above as sub-items of that item)?
I can think of complicated ways to either get the list to be the way I want -- or to read the sublist in item 1. But is there a simple way to just use SENTENCE->LIST to convert the string into a 4-item list?
Offline
Hi knubee,
I just again checked the sentence->list reportert block (it's in the green "Operators" tab), and it transforms an input of "My name is John" to an anonymous list of four items, one word each. You have to open the tools.ypr file in BYOB or import the ToolSprite.ysp file, switch to the green Operators tab, drag out the (round) reporter block named sentence->list [_] and type your sentence into the input field, and double click on the reporter block.
Please let us know if this doesn't work for you.
Thanks!
Offline
Ta da! Here's the official BYOB 3.1 release:
Macintosh
Windows installer
Windows files only
just image and changes
Jens wrote:
A few remaining glitches have been fixed, some localization issues remain, especially with non-Western codepages. Check out Brian's cool animals game!
Thanks, everybody, for the tireless testing, and for all your encouragement.
Enjoy!
--Jens
If you have 3.0, you should probably download the complete 3.1 package, which includes new help files, projects, localization, and tools.
Onward to 4.0!
Offline
MathWizz wrote:
The links are broken.
BYOB site is down.
Offline
Jens wrote:
Hi knubee,
I just again checked the sentence->list reportert block (it's in the green "Operators" tab), and it transforms an input of "My name is John" to an anonymous list of four items, one word each. You have to open the tools.ypr file in BYOB or import the ToolSprite.ysp file, switch to the green Operators tab, drag out the (round) reporter block named sentence->list [_] and type your sentence into the input field, and double click on the reporter block.
Please let us know if this doesn't work for you.
Thanks!
Yes, text can be entered directly into the sentence->list block. However, I am trying to grab user input that is (temporarily) stored in the ANSWER block (variable). Thus, the natural thing to do is create <sentence->list [answer]>. So far, so good. The resulting combination of blocks reports the user input in the form of a list of four items.
However, I want to NAME that list so I can then operate on it. Is there a straight-forward way to do this? (If it can be avoided, I would rather not add that list as item 1 of a named list)
Offline
knubee wrote:
Jens wrote:
Hi knubee,
I just again checked the sentence->list reportert block (it's in the green "Operators" tab), and it transforms an input of "My name is John" to an anonymous list of four items, one word each. You have to open the tools.ypr file in BYOB or import the ToolSprite.ysp file, switch to the green Operators tab, drag out the (round) reporter block named sentence->list [_] and type your sentence into the input field, and double click on the reporter block.
Please let us know if this doesn't work for you.
Thanks!Yes, text can be entered directly into the sentence->list block. However, I am trying to grab user input that is (temporarily) stored in the ANSWER block (variable). Thus, the natural thing to do is create <sentence->list [answer]>. So far, so good. The resulting combination of blocks reports the user input in the form of a list of four items.
However, I want to NAME that list so I can then operate on it. Is there a straight-forward way to do this? (If it can be avoided, I would rather not add that list as item 1 of a named list)
Use a variable and set the variable to the (sentence (answer) -> list).
Offline
scimonster wrote:
MathWizz wrote:
The links are broken.
BYOB site is down.
It works for me. If you guys are still having trouble, could you send me a screenshot or a more detailed report on what happens when you try it?
Offline
bharvey wrote:
scimonster wrote:
MathWizz wrote:
The links are broken.
BYOB site is down.
It works for me. If you guys are still having trouble, could you send me a screenshot or a more detailed report on what happens when you try it?
Here's the code of the page error:
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Problem loading page</title> <link rel="stylesheet" href="chrome://global/skin/netError.css" type="text/css" media="all" /> <!-- If the location of the favicon is changed here, the FAVICON_ERRORPAGE_URL symbol in toolkit/components/places/src/nsFaviconService.h should be updated. --> <link rel="icon" type="image/png" id="favicon" href="chrome://global/skin/icons/warning-16.png" /> <script type="application/javascript"><![CDATA[ // Error url MUST be formatted like this: // moz-neterror:page?e=error&u=url&d=desc // // or optionally, to specify an alternate CSS class to allow for // custom styling and favicon: // // moz-neterror:page?e=error&u=url&s=classname&d=desc // Note that this file uses document.documentURI to get // the URL (with the format from above). This is because // document.location.href gets the current URI off the docshell, // which is the URL displayed in the location bar, i.e. // the URI that the user attempted to load. function getErrorCode() { var url = document.documentURI; var error = url.search(/e\=/); var duffUrl = url.search(/\&u\=/); return decodeURIComponent(url.slice(error + 2, duffUrl)); } function getCSSClass() { var url = document.documentURI; var matches = url.match(/s\=([^&]+)\&/); // s is optional, if no match just return nothing if (!matches || matches.length < 2) return ""; // parenthetical match is the second entry return decodeURIComponent(matches[1]); } function getDescription() { var url = document.documentURI; var desc = url.search(/d\=/); // desc == -1 if not found; if so, return an empty string // instead of what would turn out to be portions of the URI if (desc == -1) return ""; return decodeURIComponent(url.slice(desc + 2)); } function retryThis(buttonEl) { // Session history has the URL of the page that failed // to load, not the one of the error page. So, just call // reload(), which will also repost POST data correctly. try { location.reload(); } catch (e) { // We probably tried to reload a URI that caused an exception to // occur; e.g. a nonexistent file. } buttonEl.disabled = true; } function initPage() { var err = getErrorCode(); // if it's an unknown error or there's no title or description // defined, get the generic message var errTitle = document.getElementById("et_" + err); var errDesc = document.getElementById("ed_" + err); if (!errTitle || !errDesc) { errTitle = document.getElementById("et_generic"); errDesc = document.getElementById("ed_generic"); } var title = document.getElementById("errorTitleText"); if (title) { title.parentNode.replaceChild(errTitle, title); // change id to the replaced child's id so styling works errTitle.id = "errorTitleText"; } var sd = document.getElementById("errorShortDescText"); if (sd) sd.textContent = getDescription(); var ld = document.getElementById("errorLongDesc"); if (ld) { ld.parentNode.replaceChild(errDesc, ld); // change id to the replaced child's id so styling works errDesc.id = "errorLongDesc"; } // remove undisplayed errors to avoid bug 39098 var errContainer = document.getElementById("errorContainer"); errContainer.parentNode.removeChild(errContainer); var className = getCSSClass(); if (className && className != "expertBadCert") { // Associate a CSS class with the root of the page, if one was passed in, // to allow custom styling. // Not "expertBadCert" though, don't want to deal with the favicon document.documentElement.className = className; // Also, if they specified a CSS class, they must supply their own // favicon. In order to trigger the browser to repaint though, we // need to remove/add the link element. var favicon = document.getElementById("favicon"); var faviconParent = favicon.parentNode; faviconParent.removeChild(favicon); favicon.setAttribute("href", "chrome://global/skin/icons/" + className + "_favicon.png"); faviconParent.appendChild(favicon); } if (className == "expertBadCert") { showSecuritySection(); } if (err == "remoteXUL") { // Remove the "Try again" button for remote XUL errors given that // it is useless. document.getElementById("errorTryAgain").style.display = "none"; } if (err == "cspFrameAncestorBlocked") { // Remove the "Try again" button for CSP frame ancestors violation, since it's // almost certainly useless. (Bug 553180) document.getElementById("errorTryAgain").style.display = "none"; } if (err == "nssBadCert") { // Remove the "Try again" button for security exceptions, since it's // almost certainly useless. document.getElementById("errorTryAgain").style.display = "none"; document.getElementById("errorPageContainer").setAttribute("class", "certerror"); addDomainErrorLink(); } else { // Remove the override block for non-certificate errors. CSS-hiding // isn't good enough here, because of bug 39098 var secOverride = document.getElementById("securityOverrideDiv"); secOverride.parentNode.removeChild(secOverride); } } function showSecuritySection() { // Swap link out, content in document.getElementById('securityOverrideContent').style.display = ''; document.getElementById('securityOverrideLink').style.display = 'none'; } /* In the case of SSL error pages about domain mismatch, see if we can hyperlink the user to the correct site. We don't want to do this generically since it allows MitM attacks to redirect users to a site under attacker control, but in certain cases it is safe (and helpful!) to do so. Bug 402210 */ function addDomainErrorLink() { // Rather than textContent, we need to treat description as HTML var sd = document.getElementById("errorShortDescText"); if (sd) { var desc = getDescription(); // sanitize description text - see bug 441169 // First, find the index of the <a> tag we care about, being careful not to // use an over-greedy regex var re = /<a id="cert_domain_link" title="([^"]+)">/; var result = re.exec(desc); if(!result) return; // Remove sd's existing children sd.textContent = ""; // Everything up to the link should be text content sd.appendChild(document.createTextNode(desc.slice(0, result.index))); // Now create the link itself var anchorEl = document.createElement("a"); anchorEl.setAttribute("id", "cert_domain_link"); anchorEl.setAttribute("title", result[1]); anchorEl.appendChild(document.createTextNode(result[1])); sd.appendChild(anchorEl); // Finally, append text for anything after the closing </a> sd.appendChild(document.createTextNode(desc.slice(desc.indexOf("</a>") + "</a>".length))); } var link = document.getElementById('cert_domain_link'); if (!link) return; var okHost = link.getAttribute("title"); var thisHost = document.location.hostname; var proto = document.location.protocol; // If okHost is a wildcard domain ("*.example.com") let's // use "www" instead. "*.example.com" isn't going to // get anyone anywhere useful. bug 432491 okHost = okHost.replace(/^\*\./, "www."); /* case #1: * example.com uses an invalid security certificate. * * The certificate is only valid for www.example.com * * Make sure to include the "." ahead of thisHost so that * a MitM attack on paypal.com doesn't hyperlink to "notpaypal.com" * * We'd normally just use a RegExp here except that we lack a * library function to escape them properly (bug 248062), and * domain names are famous for having '.' characters in them, * which would allow spurious and possibly hostile matches. */ if (endsWith(okHost, "." + thisHost)) link.href = proto + okHost; /* case #2: * browser.garage.maemo.org uses an invalid security certificate. * * The certificate is only valid for garage.maemo.org */ if (endsWith(thisHost, "." + okHost)) link.href = proto + okHost; } function endsWith(haystack, needle) { return haystack.slice(-needle.length) == needle; } ]]></script> </head> <body dir="ltr"> <!-- ERROR ITEM CONTAINER (removed during loading to avoid bug 39098) --> <!-- PAGE CONTAINER (for styling purposes only) --> <div id="errorPageContainer"> <!-- Error Title --> <div id="errorTitle"> <h1 id="errorTitleText">Server not found</h1> </div> <!-- LONG CONTENT (the section most likely to require scrolling) --> <div id="errorLongContent"> <!-- Short Description --> <div id="errorShortDesc"> <p id="errorShortDescText">Firefox can't find the server at byob.berkekey.edu.</p> </div> <!-- Long Description (Note: See netError.dtd for used XHTML tags) --> <div id="errorLongDesc"> <ul> <li>Check the address for typing errors such as <strong>ww</strong>.example.com instead of <strong>www</strong>.example.com</li> <li>If you are unable to load any pages, check your computer's network connection.</li> <li>If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.</li> </ul> </div> <!-- Override section - For ssl errors only. Removed on init for other error types. --> </div> <!-- Retry Button --> <button id="errorTryAgain" onclick="retryThis(this);">Try Again</button> </div> <!-- - Note: It is important to run the script this way, instead of using - an onload handler. This is because error pages are loaded as - LOAD_BACKGROUND, which means that onload handlers will not be executed. --> <script type="application/javascript">initPage();</script> </body> </html>
Offline
Corrected version (same links as earlier message).
Jens wrote:
please throw away the yesterday's version and take this one instead, it packages the correct help screen for the IS A __ ? reporter block. Sorry for the confusion.
EDIT: Somehow I seem to have posted this message without updating the Windows file only version on the web site. I've fixed that now, sorry! (I plead jet lag.)
Last edited by bharvey (2011-05-18 23:49:35)
Offline
scimonster wrote:
knubee wrote:
However, I want to NAME that list so I can then operate on it. Is there a straight-forward way to do this? (If it can be avoided, I would rather not add that list as item 1 of a named list)
Use a variable and set the variable to the (sentence (answer) -> list).
Oh, yes, that gives me a named variable with the list as its value. But there is no block for "variable contains [thing]". Basically, here is what I was hoping to be able to do:
1. capture user input to "answer"
2. convert the sentence in "answer" to a named list
3. test the named list for presence of keywords
Is the only way to do this to assign the input list to a variable -- and then create my own "variable contains [thing]" predicate?
Offline
3.1 is out. I wonder if there will be BYOB 3.14
Offline
knubee wrote:
But there is no block for "variable contains [thing]".
If the value of a variable is a list, you can drag the orange variable blob for that variable onto the list dropdown menu of any of the list blocks, and the block will take that variable's value as the list to operate on.
P.S. For that matter, you can just say
IF < (SENTENCE->LIST (ANSWER)) CONTAINS whatever > ...
without putting the list into a variable or anything.
Last edited by bharvey (2011-05-18 23:53:35)
Offline
bharvey wrote:
[f the value of a variable is a list, you can drag the orange variable blob for that variable onto the list dropdown menu of any of the list blocks, and the block will take that variable's value as the list to operate on.
Ah! The ability to drag blocks onto pull-down menus was the bit I was missing. With that, yes, I see a number of ways of doing what I want.
Thanks for all the help -- and all the good work on BYOB. It is really nice to be able to introduce a wider range of programming concepts and techniques with this version of Scratch!
Offline
fanofcena wrote:
BYOB is always 1 step ahead of scratch
scratch 1.4 - byob 2.0
scratch 2.0 - Byob 3.0
with all the cool new features BYOB Will soon become a pros language for experimentisation
Wrong.
Scratch 1.3 - BYOB 1.0
Scratch 1.4 - BYOB 2.0, 3.0, and 3.1
On it's own ways - Snap 4.0+
Offline
First post-official bugfix release 3.1.1:
Macintosh
Windows installer
Windows files only
just image and changes
Jens wrote:
This release fixes two bugs from 3.1:
- clones of clones were broken and once again work. Thanks, Scott, for the testing and the bug report.
- 3.1 produced garbled variable blobs under certain conditions
I didn't expect a new release so soon, OTOH never trust a first release
--Jens
Offline
Cool!
Offline
Taneb wrote:
What I still want to see is the join reporter working for scripts. And also lists.
There's an APPEND block in the tools library for lists. As for scripts, editability is still a little ways in the future, maybe 4.0 or 4.1.
Last edited by bharvey (2011-05-22 12:15:04)
Offline
14God wrote:
Hi people, its been a while since I've posted on the forum because of school.
Same
Offline
Hot off the presses: a Greek translation by
Nektarios Moumoutzis. Download it and add it to the locale folder.
Offline