Hardmath123 wrote:
http://www.imgpaste.com/r1N1.png
...
By any chance, could you give me the code for an individual block? I'd like to try making some Snap! blocks.
EDIT: I know about the empty hole in the Set block, I took that out before taking the picture. And yes, I did run the set one before.
The call block isn't needed.
Offline
Hardmath123 wrote:
It's not a very good error message, but those are coming later. You want just RUN [TREE], not RUN [CALL [TREE]]. CALL is for reporters, which Tree isn't.
By any chance, could you give me the code for an individual block? I'd like to try making some Snap! blocks.
Load Snap! in your browser, then View Source, then click on objects.js to get the latest greatest. But bear in mind that a lot of Control blocks that are currently handled as special cases will be regular blocks by the time we're done.
Offline
@Jens
When I decided to rewrite my fractals examples from Byob to Snap! I thought it was a simple formality. In fact it took me hours. The trick is that with Snap! - contrarily to Byob and Logo - you need to omit the final STOP of the IF part of the Script. See the result :
Offline
bharvey wrote:
Taneb wrote:
"Internal Error: The file could not be opened"
Hmm, I wonder if there was a problem with my download. The one on the web site is 2391793 bytes long; is that what it should be? (@roijac)
yes, it's about 26 MB, try download it again
http://dl.dropbox.com/u/38975042/BYOB-3-1-1.deb
Offline
xly wrote:
@Jens
When I decided to rewrite my fractals examples from Byob to Snap! I thought it was a simple formality. In fact it took me hours. The trick is that with Snap! - contrarily to Byob and Logo - you need to omit the final STOP of the IF part of the Script. See the result :
http://www.xleroy.net/ByobTuto/New/Snap!/ccurve.gif
show off
Offline
Well, that gave me a different error message. "The package is of bad quality: The installation of a package which violates the quality standards isn't allowed. This could cause serious problems on your computer. Please contact the person or organisation who provided this package and include the details beneath"
Offline
Taneb wrote:
Well, that gave me a different error message. "The package is of bad quality: The installation of a package which violates the quality standards isn't allowed. This could cause serious problems on your computer. Please contact the person or organisation who provided this package and include the details beneath"
try rename it to byob-3-1-1 (lower-case)
is it working now?
Offline
bharvey wrote:
Hardmath123 wrote:
By any chance, could you give me the code for an individual block? I'd like to try making some Snap! blocks.
Load Snap! in your browser, then View Source, then click on objects.js to get the latest greatest. But bear in mind that a lot of Control blocks that are currently handled as special cases will be regular blocks by the time we're done.
And the code?
EDIT: Got it. Here's a block:
Process.prototype.reportExp = function (a, b) { return Math.pow(parseFloat(a), parseFloat(b)); }; blocks.push(block( 'reporter', 'operators', '%n ^ %n', 'reportExp' ));
Last edited by Hardmath123 (2011-10-23 09:14:14)
Offline
xly wrote:
with Snap! - contrarily to Byob and Logo - you need to omit the final STOP of the IF part of the Script.
That's because we don't yet have STOP BLOCK, as opposed to STOP SCRIPT. It'll get there eventually.
Offline
Hardmath123 wrote:
Process.prototype.reportExp = function (a, b) {
return Math.pow(parseFloat(a), parseFloat(b) );
};
The plan is that you're going to be able to do things like that this way:
The callJS block will figure out the data type of the inputs and do the appropriate conversion (such as parseFloat).
Offline
^ Cool!
Last edited by shadow_7283 (2011-10-23 11:27:42)
Offline
bharvey wrote:
Hardmath123 wrote:
Process.prototype.reportExp = function (a, b) {
return Math.pow(parseFloat(a), parseFloat(b) );
};The plan is that you're going to be able to do things like that this way:
http://cs.berkeley.edu/~bh/callJS.gif
The callJS block will figure out the data type of the inputs and do the appropriate conversion (such as parseFloat).
I'm trying to make a block installer with a javascript:() bookmarklet which asks for the two codes. How do I edit the "function() =" with the 'blockspecs'? The code, I assume, can be added as a simple (global) function.
Offline
Hardmath123 wrote:
I'm trying to make a block installer with a javascript:() bookmarklet which asks for the two codes. How do I edit the "function() =" with the 'blockspecs'? The code, I assume, can be added as a simple (global) function.
Maybe I'm missing the point about bookmarklets. What is the end goal you're trying to accomplish that the proposed callJS won't do?
The reason for this plan is that we hope to have a minimum of primitive blocks, extended by both our own and user-provided libraries that define other things as custom blocks. We've even talked about moving some of the redundant Scratch blocks (e.g., CHANGE <var> BY <delta> ) into a library. So, we want users to be able to customize the language with Snap!-level programming, rather than JS-level programming. But there will be a lot of JS capabilities that couldn't be done entirely in Snap!, so we want one ring to... no, I mean, one block that will give access to the entire zoo of JS libraries.
But, for instance, we don't want to encourage users to import JS control structures (e.g., FOR loops); if it can be done in Snap!, then it should be (and it should run fast enough not to discourage users from relying on custom blocks). Not that you shouldn't program in JS if you want, but if that's what you want you should fire up Emacs and write a .js file.
Offline
bharvey wrote:
Hardmath123 wrote:
Process.prototype.reportExp = function (a, b) {
return Math.pow(parseFloat(a), parseFloat(b) );
};The plan is that you're going to be able to do things like that this way:
The callJS block will figure out the data type of the inputs and do the appropriate conversion (such as parseFloat).
Instead of this, why not add a block like (JavaScript[alert()]) that can be put into a call or run block. It looks nicer, and it adds one block instead of two (or three if a launch block is planned)
---------------------
bharvey wrote:
one ring to...
...rule them all?
Last edited by rubiks_cube_guy238 (2011-10-23 17:31:50)
Offline
rubiks_cube_guy238 wrote:
Instead of this, why not add a block like (JavaScript[alert()]) that can be put into a call or run block. It looks nicer, and it adds one block instead of two (or three if a launch block is planned)
I think your version will have to be two shapes, too; no matter how you handle the JS side of the interface, the Snap! side of the interface distinguishes blocks that report values from ones that don't.
The reason to make it JS apply (call one function) rather than eval (run some piece of code) is that we are trying to provide access to low-level (e.g., hardware interface) primitives, rather than to encourage people to write whole scripts in JS instead of in blocks.
Of course people could do that anyway by writing a JS function in a private library and then using our apply block to call it, but nevertheless we think that the two possibilities encourage different programming styles.
bharvey wrote:
one ring to...
...rule them all?
Of course, what else did you think I meant??
Offline
bharvey wrote:
Hardmath123 wrote:
I'm trying to make a block installer with a javascript:() bookmarklet which asks for the two codes. How do I edit the "function() =" with the 'blockspecs'? The code, I assume, can be added as a simple (global) function.
Maybe I'm missing the point about bookmarklets.
Oh, a primitive bookmarklet that when fired asks for the block's code, then adds that block to the library. Just for fun.
Offline
roijac wrote:
http://i.imgur.com/qUhWG.png
was bored
That's cool. (pun...) You know that the official Koch snowflake fractalizes the first and last section of each side, too, right?
Offline