Discuss Scratch

frodewin
Scratcher
500+ posts

Snap! user discussion

liam48D wrote:

Or you can use some javascript hax

[get watcher].[bring to front]


Thank you for the tipp, but how do I apply it?
Is there a possibility to execute Javascript in Snap! ? (I looked into the manual already, but did not find anything.)





You can also find my best projects here or stop at my profile and say hi!
bharvey
Scratcher
1000+ posts

Snap! user discussion

frodewin wrote:

(I looked into the manual already, but did not find anything.)
The manual isn't up to date – my fault. I'll try to squeeze in an update soon.

There's a JavascriptFunction block in Operators. Look at File>Open>Examples>JSFunction for examples of how it's used.

frodewin
Scratcher
500+ posts

Snap! user discussion

bharvey wrote:

frodewin wrote:

(I looked into the manual already, but did not find anything.)
The manual isn't up to date – my fault. I'll try to squeeze in an update soon.

There's a JavascriptFunction block in Operators. Look at File>Open>Examples>JSFunction for examples of how it's used.

Thanks a lot, the examples are very helpful and interesting!

However, I still have no idea how to apply the . hax that was suggested by liam. Executing it in a Javascript block does not work for me.



You can also find my best projects here or stop at my profile and say hi!
liam48D
Scratcher
1000+ posts

Snap! user discussion

frodewin wrote:

bharvey wrote:

frodewin wrote:

(I looked into the manual already, but did not find anything.)
The manual isn't up to date – my fault. I'll try to squeeze in an update soon.

There's a JavascriptFunction block in Operators. Look at File>Open>Examples>JSFunction for examples of how it's used.

Thanks a lot, the examples are very helpful and interesting!

However, I still have no idea how to apply the . hax that was suggested by liam. Executing it in a Javascript block does not work for me.
(Page 50, yay!)

Oops - I should have explained that the code I showed was pseudocode. What you needs to do (or anybody else) is replace that code with the actual JavaScript code.

By the way, when you click on the JS Function block with code inside, it'll report a ‘string’ that has generally the code you wrote inside. You need to stick the JS Function block inside of a call or run block in order to actually run that code, i.e. like so:
run (JS function [alert("Hello, world!")] :: operators) :: control

202e-202e-202e-202e-202e UNI-CODE~~~~~
frodewin
Scratcher
500+ posts

Snap! user discussion

liam48D wrote:

Oops - I should have explained that the code I showed was pseudocode. What you needs to do (or anybody else) is replace that code with the actual JavaScript code.

By the way, when you click on the JS Function block with code inside, it'll report a ‘string’ that has generally the code you wrote inside. You need to stick the JS Function block inside of a call or run block in order to actually run that code, i.e. like so:
run (JS function [alert("Hello, world!")] :: operators) :: control

Success! The watcher object has no “comeToFront();” method, but coding it out worked for me to make the watcher of the variable with name “varname” come to front:

run (JS function [...] :: operators) with inputs [varname] :: control

Where “…” stands for this code in the JS function:
watcher=this.findVariableWatcher(varname);
watcher.parent.add(watcher);
watcher.parent.changed();


Thanks Liam and Bharvey for your help!

Last edited by frodewin (Dec. 26, 2015 21:18:07)




You can also find my best projects here or stop at my profile and say hi!
bharvey
Scratcher
1000+ posts

Snap! user discussion

liam48D wrote:

it'll report a ‘string’
It reports a procedure!

liam48D
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

liam48D wrote:

it'll report a ‘string’
It reports a procedure!
Nah, it reports a function..

frodewin wrote:

Success!
Nice job!

202e-202e-202e-202e-202e UNI-CODE~~~~~
Jonathan50
Scratcher
1000+ posts

Snap! user discussion

liam48D wrote:

bharvey wrote:

liam48D wrote:

it'll report a ‘string’
It reports a procedure!
Nah, it reports a function..
It is the same thing!

Not yet a Knight of the Mu Calculus.
liam48D
Scratcher
1000+ posts

Snap! user discussion

Jonathan50 wrote:

liam48D wrote:

bharvey wrote:

liam48D wrote:

it'll report a ‘string’
It reports a procedure!
Nah, it reports a function..
It is the same thing!
Ehh? http://www.thesaurus.com/browse/procedure

I don't see any “function” there…

202e-202e-202e-202e-202e UNI-CODE~~~~~
bharvey
Scratcher
1000+ posts

Snap! user discussion

liam48D wrote:

Nah, it reports a function.
Technically, a function has to return a value – in Scratch/Snap! terms, it's a reporter. “Procedure” is the generic term that includes reporters and commands.

(Even more technically, the function is the correspondence between input and output values, rather than the procedure that implements it. So f(x)=2x+6 and g(x)=2(x+3) are the same function, but different procedures.)

liam48D
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

liam48D wrote:

Nah, it reports a function.
Technically, a function has to return a value – in Scratch/Snap! terms, it's a reporter. “Procedure” is the generic term that includes reporters and commands.

(Even more technically, the function is the correspondence between input and output values, rather than the procedure that implements it. So f(x)=2x+6 and g(x)=2(x+3) are the same function, but different procedures.)
Hm, I didn't know that! You learn something knew every day.

202e-202e-202e-202e-202e UNI-CODE~~~~~
blob8108
Scratcher
1000+ posts

Snap! user discussion

liam48D wrote:

You learn something knew every day.
That's what Brian's here for!

tosh · slowly becoming a grown-up adult and very confused about it
bharvey
Scratcher
1000+ posts

Snap! user discussion

blob8108 wrote:

That's what Brian's here for!
Aww, you only love me because I know everything.

blob8108
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

Aww, you only love me because I know everything.
No, it's also because you're adorably grumpy.

tosh · slowly becoming a grown-up adult and very confused about it
frodewin
Scratcher
500+ posts

Snap! user discussion

Does Snap! have a Wiki or similar thing where snippets of information can be found and put?
If no,
why not?
should Snap! stuff be added to the english Scratch wiki (after asking) or would there a need for a separate Snap Wiki ?



You can also find my best projects here or stop at my profile and say hi!
bharvey
Scratcher
1000+ posts

Snap! user discussion

frodewin wrote:

Does Snap! have a Wiki
We'll get around to it. There are Snap!-related articles in the Scratch wiki, but I don't think we should fill it up with our stuff; that might push them too far.

DrKat123
Scratcher
1000+ posts

Snap! user discussion

When i use the

(http:// []) :: reporter sensing
block, why can't i access Scratch's homepage's code?
Is it because the HTTP?

Last edited by DrKat123 (Dec. 29, 2015 04:29:04)


Moving from Scratch? Don't learn C or Java, try Snap!
it haz OOP
DrKat McKatFace
First of all I'm 100% human and humans does not have a cat face
and second, the Boaty McBoatFace/Parsey McParseFace madness has just begun

λ
Sharp, my new Scratch mod
Is my post/siggy worthy for an internet?
bharvey
Scratcher
1000+ posts

Snap! user discussion

DrKat123 wrote:

why can't i access Scratch's homepage's code?
It's because of stupid CORS. We use this:


Of course that'll only show you the html code; you'll have to request Javascript files explicitly to get those. If it works…

DrKat123
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

DrKat123 wrote:

why can't i access Scratch's homepage's code?
It's because of stupid CORS. We use this:


Of course that'll only show you the html code; you'll have to request Javascript files explicitly to get those. If it works…
I know that the http:// block shows the html code only. So that's why…
What if i used the javascript block and the http://() to display pages?
(That would work like a browser, cool )

Moving from Scratch? Don't learn C or Java, try Snap!
it haz OOP
DrKat McKatFace
First of all I'm 100% human and humans does not have a cat face
and second, the Boaty McBoatFace/Parsey McParseFace madness has just begun

λ
Sharp, my new Scratch mod
Is my post/siggy worthy for an internet?
bharvey
Scratcher
1000+ posts

Snap! user discussion

DrKat123 wrote:

What if i used the javascript block and the http://() to display pages?
(That would work like a browser, cool )
That would be an excellent project! Except you probably can't do it in a Morphic window if you're talking about running other people's JS code; you'd have to start by opening another window to run DOM code in.

Powered by DjangoBB