Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Snap! user discussion
- frodewin
- Scratcher
500+ posts
Snap! user discussion
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.)
- bharvey
- Scratcher
1000+ posts
Snap! user discussion
The manual isn't up to date – my fault. I'll try to squeeze in an update soon. (I looked into the manual already, but did not find anything.)
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
The manual isn't up to date – my fault. I'll try to squeeze in an update soon. (I looked into the manual already, but did not find anything.)
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.
- liam48D
- Scratcher
1000+ posts
Snap! user discussion
(Page 50, yay!)The manual isn't up to date – my fault. I'll try to squeeze in an update soon. (I looked into the manual already, but did not find anything.)
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.
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
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)
- liam48D
- Scratcher
1000+ posts
Snap! user discussion
Nah, it reports a function..It reports a it'll report a ‘string’procedure!
Nice job! Success!
202e-202e-202e-202e-202e UNI-CODE~~~~~
- Jonathan50
- Scratcher
1000+ posts
Snap! user discussion
It is the same thing!Nah, it reports a function..It reports a it'll report a ‘string’procedure!
Not yet a Knight of the Mu Calculus.
- liam48D
- Scratcher
1000+ posts
Snap! user discussion
Ehh? http://www.thesaurus.com/browse/procedureIt is the same thing!Nah, it reports a function..It reports a it'll report a ‘string’procedure!
I don't see any “function” there…
202e-202e-202e-202e-202e UNI-CODE~~~~~
- bharvey
- Scratcher
1000+ posts
Snap! user discussion
function.Technically, a function has to return a value – in Scratch/Snap Nah, it reports a ! 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
Hm, I didn't know that! You learn something knew every day.function.Technically, a function has to return a value – in Scratch/Snap Nah, it reports a ! 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.)
202e-202e-202e-202e-202e UNI-CODE~~~~~
- bharvey
- Scratcher
1000+ posts
Snap! user discussion
Aww, you only love me because I know everything. That's what Brian's here for!
- 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 ?
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 ?
- bharvey
- Scratcher
1000+ posts
Snap! user discussion
We'll get around to it. There are Snap Does Snap! have a Wiki!-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
Is it because the HTTP?
(http:// []) :: reporter sensingblock, 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
It's because of stupid CORS. We use this: why can't i access Scratch's homepage's code?
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
I know that the http:// block shows the html code only. So that's why…It's because of stupid CORS. We use this: why can't i access Scratch's homepage's code?
Of course that'll only show you the html code; you'll have to request Javascript files explicitly to get those. If it works…
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
http://() to display pages?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. What if i used the javascript block and the
(That would work like a browser, cool )