Discuss Scratch

blob8108
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

But why is the left arrowhead smaller than the right one?
Unicode is weird.

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

Snap! user discussion

◀◀◀▶▶▶

liam48D
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

◀◀◀▶▶▶
I don't know what's happened to this world, with even the original posters spamming on their own topics..

202e-202e-202e-202e-202e UNI-CODE~~~~~
xly
Scratcher
100+ posts

Snap! user discussion

xly wrote:

Dragonboy105 wrote:

How do you make lists in the blocks?
define my question
ask [How do you make lists work?] and wait 1 week // category=sensing

One possible solution is to define your list as a long formatted string “www”,“yyyy”,“zzzz” SET to a SCRIPT VARIABLE in your block-list
Then Snap! has all the necessary tools to process this string and report it as a “true” LIST.
This block-list can be saved, exported and re-imported like a block.
I suggest to load the reimported list into a local list to avoid the long decoding process each time you need to explore it.

My understanding of the question was : how to easily save (or export) a list of data without saving a whole project, considering that Snap! is not convenient to export/import list of data. The way I mention allows to export a list of data embedded into a block, which can be easily exported/imported.
I use this method to store a list of 140 colours having a standardized name like aquamarine,coral…(name+hexa colour value).
liam48D
Scratcher
1000+ posts

Snap! user discussion

I've been having trouble with returning a command. I want my command to optionally take an input - resolve value - but I get an error trying to access that variable if it wasn't passed.

The command looks like this:
(command) args: (resolve value) :: grey hat
say (join [It's done, with value: ] (resolve value)
When I run it like this, it works:
run (command) with arguments [Foo] :: control // "It's done, with value: Foo"
But when I run it like this:
run (command) :: control // should be "It's done, with value: "
..I get an error: a variable of name ‘resolve value’ does not exist in this context.

Is there any way to make a command/reporter take an optional value? I can mimic the ideal effect like so:
run (command) with arguments [] :: control // "It's done, with value: "
But that really doesn't look nice.

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

Snap! user discussion

Couldn't you just make another command that doesn't take an argument
liam48D
Scratcher
1000+ posts

Snap! user discussion

ChocolatePi wrote:

Couldn't you just make another command that doesn't take an argument
Not really, because the command is returned from a custom block.

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

Snap! user discussion

liam48D wrote:

ChocolatePi wrote:

Couldn't you just make another command that doesn't take an argument
Not really, because the command is returned from a custom block.
You mean you're returning a function?

Show us all the code, kid! (just kidding we're the same age)
bharvey
Scratcher
1000+ posts

Snap! user discussion

liam48D wrote:

Is there any way to make a command/reporter take an optional value?
The only thing I can think of is to make it a variadic input. (Click the “multiple inputs” button in the long form input dialog.)

liam48D
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

liam48D wrote:

Is there any way to make a command/reporter take an optional value?
The only thing I can think of is to make it a variadic input. (Click the “multiple inputs” button in the long form input dialog.)
Oops, I mean the ring block!

EDIT: This seems to work:
run (the script ::grey ring) :: control
run (the script ::grey ring) with inputs [Foo] :: control

the script :: grey hat
script variables (input) :: grey
set [input v] to []
say (join [input is: ] (input)) for (1) secs
Unfortunately I can't see how it would work with multiple inputs.

Last edited by liam48D (Jan. 7, 2016 01:25:31)


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

Snap! user discussion

I can't wait until first-class costumes where I can make an ironic “engraved invitation” function that returns an actual engraved invitation!
bharvey
Scratcher
1000+ posts

Snap! user discussion

liam48D wrote:

Unfortunately I can't see how it would work with multiple inputs.
Oh. Yeah, you don't get long form input dialogs with rings (but you should, @Jens). Sorry.

bharvey
Scratcher
1000+ posts

Snap! user discussion

ChocolatePi wrote:

I can't wait until first-class costumes where I can make an ironic “engraved invitation” function that returns an actual engraved invitation!
It's text boxes you can't wait for. Me neither. (A text box will be a special kind of costume that contains text instead of pixels, and can be edited either by the user clicking in it or programmatically.)

Jens
Scratcher
100+ posts

Snap! user discussion

Snap doesn't have optional inputs, as many other programming languages don't have optional parameters either. But - like other programming languages, too - Snap lets you be explicit about what you want to do. You should be able to infer the type or value of the “optional” argument and depending on that either execute “RUN” or “RUN WITH INPUTS”. What do you think?
liam48D
Scratcher
1000+ posts

Snap! user discussion

Jens wrote:

Snap doesn't have optional inputs, as many other programming languages don't have optional parameters either. But - like other programming languages, too - Snap lets you be explicit about what you want to do. You should be able to infer the type or value of the “optional” argument and depending on that either execute “RUN” or “RUN WITH INPUTS”. What do you think?
Yeah, but maybe add a null block. Though null can be worked around like this:
(null :: operators) :: control hat
report (call (JavaScript function [return null] :: operators) :: control) :: control cap

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

Snap! user discussion

bharvey wrote:

Me neither

Me neither
liam48D
Scratcher
1000+ posts

Snap! user discussion

s_federici wrote:

bharvey wrote:

Me neither

Me neither
Nor I

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

Snap! user discussion

bharvey wrote:

What is this? I couldn't find it even in http://snap.berkeley.edu/snapsource/dev/snap.html
djdolphin
Scratcher
1000+ posts

Snap! user discussion

s_federici wrote:

bharvey wrote:

What is this? I couldn't find it even in http://snap.berkeley.edu/snapsource/dev/snap.html
I'm pretty sure it's enabled by default now and the setting was removed. The when <> block is in the control category.

!
s_federici
Scratcher
500+ posts

Snap! user discussion

djdolphin wrote:

I'm pretty sure it's enabled by default now and the setting was removed. The when <> block is in the control category.
I see thanks

Powered by DjangoBB

Standard | Mobile