Discuss Scratch

cs293450
Scratcher
100+ posts

"if () then () else ()" control block.

(if <> then [] else [])
If the condition is true, reports in the first slot, if not, reports in the second slot.
alexphan
Scratcher
1000+ posts

"if () then () else ()" control block.

define if <condition> then [1] else [2]
if <condition :: custom args> then
set [out v] to (1 :: custom args)
else
set [out v] to (2 :: custom args)
DaSpudLord
Scratcher
1000+ posts

"if () then () else ()" control block.

alexphan wrote:

define if <condition> then [1] else [2]
if <condition :: custom args> then
set [out v] to (1 :: custom args)
else
set [out v] to (2 :: custom args)
^^^
Semi-support.
cs293450
Scratcher
100+ posts

"if () then () else ()" control block.

if <...> then
...
else
...
end
da-maker
Scratcher
100+ posts

"if () then () else ()" control block.

cs293450 wrote:

(if <> then [] else [])
If the condition is true, reports in the first slot, if not, reports in the second slot.
That isn't supposed to be a control block?
(if <> then [] else []:: operators)
matey1234
Scratcher
1000+ posts

"if () then () else ()" control block.

da-maker wrote:

cs293450 wrote:

(if <> then [] else [])
If the condition is true, reports in the first slot, if not, reports in the second slot.
That isn't supposed to be a control block?
(if <> then [] else []:: operators)
That's not control, that's operators ;p

(if <> then [] else []:: control)
^ This is control.

DaSpudLord wrote:

alexphan wrote:

define if <condition> then [1] else [2]
if <condition :: custom args> then
set [out v] to (1 :: custom args)
else
set [out v] to (2 :: custom args)
^^^
Semi-support.
Also, this ^^^
Dragonboy105
Scratcher
53 posts

"if () then () else ()" control block.

It should be operators because operators is logic as well.And also controls has no reporters and would no be right. +Semi-Support
brainstorm101
Scratcher
1000+ posts

"if () then () else ()" control block.

cs293450 wrote:

(if <> then [] else [])
If the condition is true, reports in the first slot, if not, reports in the second slot.
This is literally the exact same thing as the if then else block that is currently in Scratch, no support.
pvz_pro
Scratcher
500+ posts

"if () then () else ()" control block.

no support
if <> then
set [report v] to [0]
else
set [report v] to [1]
end
alexphan
Scratcher
1000+ posts

"if () then () else ()" control block.

cs293450 wrote:

if <...> then
...
else
...
end

You just gave a workaround to your own suggestion…? xD
da-maker
Scratcher
100+ posts

"if () then () else ()" control block.

matey1234 wrote:

da-maker wrote:

cs293450 wrote:

(if <> then [] else [])
If the condition is true, reports in the first slot, if not, reports in the second slot.
That isn't supposed to be a control block?
(if <> then [] else []:: operators)
That's not control, that's operators ;p

(if <> then [] else []:: control)
^ This is control.

I know. Read carefully.
"That isn't supposed to be a control block?"
ipaddude
Scratcher
100+ posts

"if () then () else ()" control block.

idk
it would seem kinda cool

it's built into javascript and probably wouldn't be very hard to implement (
some_boolean?"the boolean is true":"the boolean is false"
)

maybe it could be like this
(if <some condition::operators> then [value 1] otherwise [value 2]::operators)

ik it would be confusing to new scratchers but they wouldnt even need to touch it
it's just a convenient shorthand
sportfan999
Scratcher
1000+ posts

"if () then () else ()" control block.

Here's a helpful workaround:
define if <some condition> then (value1)otherwise(value2)
if <condition::custom> then
set [var v] to (value1::custom)
else
set [var v] to (value2::custom)
ipaddude
Scratcher
100+ posts

"if () then () else ()" control block.

sportfan999 wrote:

Here's a helpful workaround:
define if <some condition> then (value1)otherwise(value2)
if <condition::custom> then
set [var v] to (value1::custom)
else
set [var v] to (value2::custom)
that would work well if scratch made functions with return values
MDCCCLXVII
Scratcher
1000+ posts

"if () then () else ()" control block.

ipaddude wrote:

(if <> then [] else [] :: operators)
Work-aroundable in Scratch, as a stack block:
define if <test> then (true) else (false)
if <test> then
set [result v] to (true)



else
set [result v] to (false)
end
This block is included in Snap! and some Scratch modifications.
gosoccerboy5
Scratcher
1000+ posts

"if () then () else ()" control block.

You can also directly build it into the code, too, instead of making a custom block.
Also duplicate topic? Not sure if there's an older one
ipaddude
Scratcher
100+ posts

"if () then () else ()" control block.

gosoccerboy5 wrote:

You can also directly build it into the code, too, instead of making a custom block.
Also duplicate topic? Not sure if there's an older one
good point
Ihatr
Scratcher
1000+ posts

"if () then () else ()" control block.

To be honest, the workaround is incredibly easy to understand and use, so I don't think a new block is needed for something as simple as this.
Greg8128
Scratcher
500+ posts

"if () then () else ()" control block.

MDCCCLXVII wrote:

ipaddude wrote:

(if <> then [] else [] :: operators)
Work-aroundable in Scratch, as a stack block:
define if <test> then (true) else (false)
if <test> then
set [result v] to (true)



else
set [result v] to (false)
end
This block is included in Snap! and some Scratch modifications.

Not a workaround. An essential feature of the ternary operator is that it only evaluates the return value that needs to be evaluated. This feature would be necessary if Scratch could have recursive reporters, but even without that it would be nice as an optimization.
portalpower
Scratcher
1000+ posts

"if () then () else ()" control block.

please stop blockspamming

Powered by DjangoBB