Discuss Scratch

catsaregreat
Scratcher
3 posts

Can you comment out code in Scratch?

Hi, I have some code I would like to keep around in one of my projects, but would like for it to be ignored at runtime. Is there anyway to comment out code in Scratch?

Thanks!

Last edited by catsaregreat (June 1, 2013 13:02:57)

OrcaCat
Scratcher
1000+ posts

Can you comment out code in Scratch?

Yeah, you can! Right click anywhere (or shift-click, if that doesn't work) and click “Add comment”. Hope this helps!

Oh, to disable code? Just unstack it from the hat block, then put a note to restack it later

Last edited by OrcaCat (June 1, 2013 13:28:01)



mwiedmann
Scratcher
100+ posts

Can you comment out code in Scratch?

catsaregreat wrote:

Hi, I have some code I would like to keep around in one of my projects, but would like for it to be ignored at runtime. Is there anyway to comment out code in Scratch?

Thanks!

You can just drag in into the code area for the sprite where it is not hooked up at all to any events. It will just float in the code area and not run. You can then slide it back in when you are ready to use it.

Another thing I do is to put experimental code into its own block, use the “make a block” feature. At the beginning of that block put a “if testing=1 then” around the whole thing. You can then turn the testing variable on/off when you want/don't want the testing code to run.
Zparx
Scratcher
500+ posts

Can you comment out code in Scratch?

Yes! Refer to the image below:



The chunk of code in the upper left of the image will not run with your project. They will just sit there. The chunk on the lower left WILL run with your project because of the “When green flag pressed” hat. All of the pieces of code on the right are event hats and will run any code you have attatched to them given the corresponding event.


Hope this helped! Scratch on.

- Z

Last edited by Zparx (June 1, 2013 13:58:21)

danchadders
Scratcher
10 posts

Can you comment out code in Scratch?

when green flag clicked
forever

define jj:o:D:D:D
end

<html>
<body bgcolor = "red">
<p>hi
</p>
</body
</html>
when green flag clicked
forever


say
[have fun on scratch] for (2) secs
:lol:
end
<html>
<body bgcolor = “red”>
<p>hi
</p>
</body
</html>
MCjason2
Scratcher
41 posts

Can you comment out code in Scratch?

danchadders wrote:

when green flag clicked
forever

define jj:o:D:D:D
end

when this sprite clicked
move (46) steps to (danchadders)
say [Your Correct!] to (danchadders)

bradhoover
Scratcher
1 post

Can you comment out code in Scratch?

hello my name is
clearsky777
Scratcher
7 posts

Can you comment out code in Scratch?

Hi! how do u put a comment in a project?
BookOwl
Scratcher
1000+ posts

Can you comment out code in Scratch?

Zparx wrote:

Yes! Refer to the image below:


<snip>
- Z
???

who needs signatures
purplebook163
Scratcher
500+ posts

Can you comment out code in Scratch?

You can not comment out code in Scratch like in JavaScript or HTML, but you can drag two blocks apart from each others so they are still next to each other, just not attached and functioning.

I hope this helps! If you have any questions, please ask em on my profile.



You can ask me anything, even if it's not Scratch related, on my profile. Use this cloud to write out cloud variables in the forums. ☁

Desktop: My browser/operating system: Windows 7, Firefox 38.0 and/or Chrome 43.0.2357.130, Flash 18.0 (release 0);
Dad's Laptop: My browser/operating system: Windows 7, Firefox 38.0 and/or Chrome, Flash 18.0 (release 0);
Tablet: My browser/operating system: Android Linux 4.4.2, Chrome 43.0.2357.93, No Flash version;
My Lapotop: , Flash 24.0 (release 0)

See a flappy bird game I made. Let me know if you beat my high score of 2!
deck26
Scratcher
1000+ posts

Can you comment out code in Scratch?

The problem with splitting a block of code is that if you want to run the code after the section you're ‘commenting out’ you have to join that back on and it can then be confusing where the original code was.

Another option is to stick an if round the code and give it something you know will be false

normal code
if <[1] = [2]> then
commented out code
end
normal code
This makes it easy to put the code back ( if 1=1) while still testing and the if can be removed once you're done with it.
LTGRemixer
Scratcher
11 posts

Can you comment out code in Scratch?

deck26 wrote:

The problem with splitting a block of code is that if you want to run the code after the section you're ‘commenting out’ you have to join that back on and it can then be confusing where the original code was.

Another option is to stick an if round the code and give it something you know will be false

normal code
if <[1] = [2]> then
commented out code
end
normal code
This makes it easy to put the code back ( if 1=1) while still testing and the if can be removed once you're done with it.


Wow I love this idea deck! I've been struggling with this problem for ages - coming up with all kinds of weird code placement protocols for “commented out” code. Thanks!
Paddle2See
Scratch Team
1000+ posts

Can you comment out code in Scratch?

Since this topic hasn't seen a new post from the topic owner in a long time, I'm going to assume that it is dead and close the topic. If it still is alive, the topic owner just needs to use the Report button to ask a mod to reopen it

Scratch Team Member, kayak and pickleball enthusiast, cat caregiver.

This is my forum signature! On a forum post, it is okay for Scratchers to advertise in their forum signature. The signature is the stuff that shows up below the horizontal line on the post. It will show up on every post I make.
(credit to Za-Chary)



;

Powered by DjangoBB

Standard | Mobile