This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-07-07 08:01:00

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

positive/negative

I made a drop down list for positive/negative. I get an error message if I try using the list and if I use the block at all then it reports 'Error!'. Here's my code for this:

Code:

 ('%P of %n' #r #negative: 'negative'

That's from Scratch-Objects->ScriptableScratchMorph->Class->blockspecs->blockspecs

I'm not doing everything on the page of Scratch-Blocks->CommandBlockMorph->--all-- ->
uncoloredArgMorphFor: I'm just doing my list because I can't copy off of that for some reason.

Code:

 $P = t2 IfTrue: [ChoiceOrExpressionArgMorph new getOptionsSelector: #negpos;
choice: 'negative'

Here's Scratch-Objects->ScriptableScratchMorph->other ops-> negative:

Code:

 
negative: t1 to:t2
t2 < 0 and t1 = 'positive'
IfTrue: [^ t2 + t2* t2].
t2 > 0 and t1 = 'negative'
IfTrue: [^ t2 - t2* t2].
^ 'Error!'

Now, if you remember
Scratch-Objects->ScriptableScratchMorph->Class->blockspecs->blockspecs
broadcasted to make the method posneg Here's 
Scratch-Objects>ScriptableScratchMorph->other ops-> negpos:

Code:

 
negpos
^ #('negative' 'positive')

Thanks for using your time to help me. You guys are awesome!

Offline

 

#2 2011-07-07 09:01:20

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: positive/negative

uncoloredargmorph:

$P = t2 IfTrue: [ChoiceOrExpressionArgMorph new getOptionsSelector: #negpos;
choice: 'negative'.

method:

Code:

negative: t1 to: t2
t1 = 'positive' ifTrue: [^ t2 abs].
t1 = 'negative' ifTrue: [^ (t2 abs) * -1].
^ self error

Not sure if these will work...
Keep your other stuff.

Offline

 

#3 2011-07-07 09:02:33

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Re: positive/negative

thanks! But still nothing. sad

Last edited by ImagineIt (2011-07-07 09:04:49)

Offline

 

#4 2011-07-08 13:02:20

GP1
Scratcher
Registered: 2009-07-06
Posts: 1000+

Re: positive/negative

You can only cut-and-paste, you can't copy-and-pste for some reason, I don't know why, for some reason


I am currently http://blocks.scratchr.org/API.php?user=GP1&amp;action=onlineStatus&amp;type=imagehttp://blocks.scratchr.org/API.php?user=GP1&amp;action=onlineStatus&amp;type=text and I finally got over 1000 posts.

Offline

 

#5 2011-07-08 13:25:58

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: positive/negative

GP1 wrote:

You can only cut-and-paste, you can't copy-and-pste for some reason, I don't know why, for some reason

In Bingo, I modified the 'copy' menu entry so that it cuts, then pastes automatically. It looks like nothing happened but it copied the stuff to the clipboard. Useful when your ALT key is broken  wink

(Consider this post as a rare occasion where I have internet during vacation)

Offline

 

Board footer