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

#3001 2012-07-06 10:52:13

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: ITopic: Welcome to your local block library!

danwoodski wrote:

Randomno wrote:

Hi. I'm attempting to make a Panther block named 'number of letter $String$ in the alphabet'. The code is:

Code:

t1 = a ifTrue: [^ '1].
t1 = b ifTrue: [^ '2'].
t1 = c ifTrue: [^ '3'].
t1 = d ifTrue: [^ '4'].
t1 = e ifTrue: [^ '5'].
t1 = f ifTrue: [^ '6'].
t1 = g ifTrue: [^ '7'].
t1 = h ifTrue: [^ '8'].
t1 = i ifTrue: [^ '9'].
t1 = j ifTrue: [^ '10'].
t1 = k ifTrue: [^ '11'].
t1 = l ifTrue: [^ 12l'].
t1 = m ifTrue: [^ '13'].
t1 = n ifTrue: [^ '14'].
t1 = o ifTrue: [^ '15'].
t1 = p ifTrue: [^ '16'].
t1 = q ifTrue: [^ '17'].
t1 = r ifTrue: [^ '18'].
t1 = s ifTrue: [^ '19'].
t1 = t ifTrue: [^ '20'].
t1 = u ifTrue: [^ '21'].
t1 = v ifTrue: [^ '22'].
t1 = w ifTrue: [^ '23'].
t1 = x ifTrue: [^ '24'].
t1 = y ifTrue: [^ '25'].
t1 = z ifTrue: [^ '26'].
^ self error

Any idea how to fix it?

Try fixing a and l-the quotes are messed up...

You have several mistakes. You could use ascii. You have syntax errors. And you shouldn't use 'self error' in blocks.
Here's a better code

Code:

number of letter $String$ in the alphabet

Code:

| t2 |
t2 _ t1 first.
t2 isLetter ifFalse: [^ 0].
t2 isLowercase ifTrue: [^ t2 asciiValue - 96].
t2 isUppercase ifTrue: [^ t2 asciiValue - 64].

Offline

 

#3002 2012-07-06 12:16:52

Randomno
Scratcher
Registered: 2012-06-04
Posts: 39

Re: ITopic: Welcome to your local block library!

dreamod wrote:

danwoodski wrote:

Randomno wrote:

Hi. I'm attempting to make a Panther block named 'number of letter $String$ in the alphabet'. The code is:

Code:

t1 = a ifTrue: [^ '1].
t1 = b ifTrue: [^ '2'].
t1 = c ifTrue: [^ '3'].
t1 = d ifTrue: [^ '4'].
t1 = e ifTrue: [^ '5'].
t1 = f ifTrue: [^ '6'].
t1 = g ifTrue: [^ '7'].
t1 = h ifTrue: [^ '8'].
t1 = i ifTrue: [^ '9'].
t1 = j ifTrue: [^ '10'].
t1 = k ifTrue: [^ '11'].
t1 = l ifTrue: [^ 12l'].
t1 = m ifTrue: [^ '13'].
t1 = n ifTrue: [^ '14'].
t1 = o ifTrue: [^ '15'].
t1 = p ifTrue: [^ '16'].
t1 = q ifTrue: [^ '17'].
t1 = r ifTrue: [^ '18'].
t1 = s ifTrue: [^ '19'].
t1 = t ifTrue: [^ '20'].
t1 = u ifTrue: [^ '21'].
t1 = v ifTrue: [^ '22'].
t1 = w ifTrue: [^ '23'].
t1 = x ifTrue: [^ '24'].
t1 = y ifTrue: [^ '25'].
t1 = z ifTrue: [^ '26'].
^ self error

Any idea how to fix it?

Try fixing a and l-the quotes are messed up...

You have several mistakes. You could use ascii. You have syntax errors. And you shouldn't use 'self error' in blocks.
Here's a better code

Code:

number of letter $String$ in the alphabet

Code:

| t2 |
t2 _ t1 first.
t2 isLetter ifFalse: [^ 0].
t2 isLowercase ifTrue: [^ t2 asciiValue - 96].
t2 isUppercase ifTrue: [^ t2 asciiValue - 64].

I'll give it a go, but I'm using Panther to make this and I don't remember any blocks needing | t1 t2 | stuff. By the way, this is mainly nicked off a block which does the opposite.


http://img209.imageshack.us/img209/5524/randomno.png
I do stuff with stuff. I also stuff stuff.

Offline

 

#3003 2012-07-06 12:21:28

Randomno
Scratcher
Registered: 2012-06-04
Posts: 39

Re: ITopic: Welcome to your local block library!

I fixed a and l but now it's returning "nil".


http://img209.imageshack.us/img209/5524/randomno.png
I do stuff with stuff. I also stuff stuff.

Offline

 

#3004 2012-07-06 12:24:23

Randomno
Scratcher
Registered: 2012-06-04
Posts: 39

Re: ITopic: Welcome to your local block library!

The ascii one worked.  neutral  This is why I shouldn't try these.


http://img209.imageshack.us/img209/5524/randomno.png
I do stuff with stuff. I also stuff stuff.

Offline

 

#3005 2012-07-08 20:39:18

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: ITopic: Welcome to your local block library!

danwoodski wrote:

Randomno wrote:

Hi. I'm attempting to make a Panther block named 'number of letter $String$ in the alphabet'. The code is:

Code:

t1 = a ifTrue: [^ '1].
t1 = b ifTrue: [^ '2'].
t1 = c ifTrue: [^ '3'].
t1 = d ifTrue: [^ '4'].
t1 = e ifTrue: [^ '5'].
t1 = f ifTrue: [^ '6'].
t1 = g ifTrue: [^ '7'].
t1 = h ifTrue: [^ '8'].
t1 = i ifTrue: [^ '9'].
t1 = j ifTrue: [^ '10'].
t1 = k ifTrue: [^ '11'].
t1 = l ifTrue: [^ 12l'].
t1 = m ifTrue: [^ '13'].
t1 = n ifTrue: [^ '14'].
t1 = o ifTrue: [^ '15'].
t1 = p ifTrue: [^ '16'].
t1 = q ifTrue: [^ '17'].
t1 = r ifTrue: [^ '18'].
t1 = s ifTrue: [^ '19'].
t1 = t ifTrue: [^ '20'].
t1 = u ifTrue: [^ '21'].
t1 = v ifTrue: [^ '22'].
t1 = w ifTrue: [^ '23'].
t1 = x ifTrue: [^ '24'].
t1 = y ifTrue: [^ '25'].
t1 = z ifTrue: [^ '26'].
^ self error

Any idea how to fix it?

Try fixing a and l-the quotes are messed up...

Your post is number 3000 on this thread.   cool

Randomno wrote:

The ascii one worked.  neutral  This is why I shouldn't try these.

Your original code (see above quote) was fine, except for two things:

1.  The return for l is messed up: it returns '12l' instead of '12'.
2.  The letters should be in quotes ('a' instead of a).

Also, putting the numbers in quotes isn't necessary.

Last edited by Greenatic (2012-07-08 20:42:32)

Offline

 

#3006 2012-07-09 01:06:16

Randomno
Scratcher
Registered: 2012-06-04
Posts: 39

Re: ITopic: Welcome to your local block library!

Greenatic wrote:

danwoodski wrote:

Randomno wrote:

Hi. I'm attempting to make a Panther block named 'number of letter $String$ in the alphabet'. The code is:

Code:

t1 = a ifTrue: [^ '1].
t1 = b ifTrue: [^ '2'].
t1 = c ifTrue: [^ '3'].
t1 = d ifTrue: [^ '4'].
t1 = e ifTrue: [^ '5'].
t1 = f ifTrue: [^ '6'].
t1 = g ifTrue: [^ '7'].
t1 = h ifTrue: [^ '8'].
t1 = i ifTrue: [^ '9'].
t1 = j ifTrue: [^ '10'].
t1 = k ifTrue: [^ '11'].
t1 = l ifTrue: [^ 12l'].
t1 = m ifTrue: [^ '13'].
t1 = n ifTrue: [^ '14'].
t1 = o ifTrue: [^ '15'].
t1 = p ifTrue: [^ '16'].
t1 = q ifTrue: [^ '17'].
t1 = r ifTrue: [^ '18'].
t1 = s ifTrue: [^ '19'].
t1 = t ifTrue: [^ '20'].
t1 = u ifTrue: [^ '21'].
t1 = v ifTrue: [^ '22'].
t1 = w ifTrue: [^ '23'].
t1 = x ifTrue: [^ '24'].
t1 = y ifTrue: [^ '25'].
t1 = z ifTrue: [^ '26'].
^ self error

Any idea how to fix it?

Try fixing a and l-the quotes are messed up...

Your post is number 3000 on this thread.   cool

Randomno wrote:

The ascii one worked.  neutral  This is why I shouldn't try these.

Your original code (see above quote) was fine, except for two things:

1.  The return for l is messed up: it returns '12l' instead of '12'.
2.  The letters should be in quotes ('a' instead of a).

Also, putting the numbers in quotes isn't necessary.

I fixed the errors but it returns "nil". Any ideas?


http://img209.imageshack.us/img209/5524/randomno.png
I do stuff with stuff. I also stuff stuff.

Offline

 

#3007 2012-07-09 14:16:12

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: ITopic: Welcome to your local block library!

Randomno wrote:

Greenatic wrote:

danwoodski wrote:


Try fixing a and l-the quotes are messed up...

Your post is number 3000 on this thread.   cool

Randomno wrote:

The ascii one worked.  neutral  This is why I shouldn't try these.

Your original code (see above quote) was fine, except for two things:

1.  The return for l is messed up: it returns '12l' instead of '12'.
2.  The letters should be in quotes ('a' instead of a).

Also, putting the numbers in quotes isn't necessary.

I fixed the errors but it returns "nil". Any ideas?

What's your current code?

Offline

 

#3008 2012-07-09 16:35:15

Randomno
Scratcher
Registered: 2012-06-04
Posts: 39

Re: ITopic: Welcome to your local block library!

Greenatic wrote:

Randomno wrote:

Greenatic wrote:


Your post is number 3000 on this thread.   cool


Your original code (see above quote) was fine, except for two things:

1.  The return for l is messed up: it returns '12l' instead of '12'.
2.  The letters should be in quotes ('a' instead of a).

Also, putting the numbers in quotes isn't necessary.

I fixed the errors but it returns "nil". Any ideas?

What's your current code?

Code:

t1 = a ifTrue: [^ 1].
t1 = b ifTrue: [^ 2].
t1 = c ifTrue: [^ 3].
t1 = d ifTrue: [^ 4].
t1 = e ifTrue: [^ 5].
t1 = f ifTrue: [^ 6].
t1 = g ifTrue: [^ 7].
t1 = h ifTrue: [^ 8].
t1 = i ifTrue: [^ 9].
t1 = j ifTrue: [^ 10].
t1 = k ifTrue: [^ 11].
t1 = l ifTrue: [^ 12].
t1 = m ifTrue: [^ 13].
t1 = n ifTrue: [^ 14].
t1 = o ifTrue: [^ 15].
t1 = p ifTrue: [^ 16].
t1 = q ifTrue: [^ 17].
t1 = r ifTrue: [^ 18].
t1 = s ifTrue: [^ 19].
t1 = t ifTrue: [^ 20].
t1 = u ifTrue: [^ 21].
t1 = v ifTrue: [^ 22].
t1 = w ifTrue: [^ 23].
t1 = x ifTrue: [^ 24].
t1 = y ifTrue: [^ 25].
t1 = z ifTrue: [^ 26].

Somehow the code automatically took off the apostrophes.

UPDATE: I've got it! You need apostrophes round the letters. *Facepalm*

Last edited by Randomno (2012-07-09 16:36:35)


http://img209.imageshack.us/img209/5524/randomno.png
I do stuff with stuff. I also stuff stuff.

Offline

 

#3009 2012-07-09 16:45:10

Randomno
Scratcher
Registered: 2012-06-04
Posts: 39

Re: ITopic: Welcome to your local block library!

And with that, I'd like to submit this code to the block library (Scratch and Panther):

Code:

t1 = 'a' ifTrue: [^ 1].
t1 = 'b' ifTrue: [^ 2].
t1 = 'c' ifTrue: [^ 3].
t1 = 'd' ifTrue: [^ 4].
t1 = 'e' ifTrue: [^ 5].
t1 = 'f' ifTrue: [^ 6].
t1 = 'g' ifTrue: [^ 7].
t1 = 'h' ifTrue: [^ 8].
t1 = 'i' ifTrue: [^ 9].
t1 = 'j' ifTrue: [^ 10].
t1 = 'k' ifTrue: [^ 11].
t1 = 'l' ifTrue: [^ 12].
t1 = 'm' ifTrue: [^ 13].
t1 = 'n' ifTrue: [^ 14].
t1 = 'o' ifTrue: [^ 15].
t1 = 'p' ifTrue: [^ 16].
t1 = 'q' ifTrue: [^ 17].
t1 = 'r' ifTrue: [^ 18].
t1 = 's' ifTrue: [^ 19].
t1 = 't' ifTrue: [^ 20].
t1 = 'u' ifTrue: [^ 21].
t1 = 'v' ifTrue: [^ 22].
t1 = 'w' ifTrue: [^ 23].
t1 = 'x' ifTrue: [^ 24].
t1 = 'y' ifTrue: [^ 25].
t1 = 'z' ifTrue: [^ 26].

Scratch just needs

Code:

| t1 |
t1 _ ''.

at the top. The ascii one would be good to add too.


http://img209.imageshack.us/img209/5524/randomno.png
I do stuff with stuff. I also stuff stuff.

Offline

 

#3010 2012-07-09 22:26:46

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: ITopic: Welcome to your local block library!

Randomno wrote:

And with that, I'd like to submit this code to the block library (Scratch and Panther):

Code:

t1 = 'a' ifTrue: [^ 1].
t1 = 'b' ifTrue: [^ 2].
t1 = 'c' ifTrue: [^ 3].
t1 = 'd' ifTrue: [^ 4].
t1 = 'e' ifTrue: [^ 5].
t1 = 'f' ifTrue: [^ 6].
t1 = 'g' ifTrue: [^ 7].
t1 = 'h' ifTrue: [^ 8].
t1 = 'i' ifTrue: [^ 9].
t1 = 'j' ifTrue: [^ 10].
t1 = 'k' ifTrue: [^ 11].
t1 = 'l' ifTrue: [^ 12].
t1 = 'm' ifTrue: [^ 13].
t1 = 'n' ifTrue: [^ 14].
t1 = 'o' ifTrue: [^ 15].
t1 = 'p' ifTrue: [^ 16].
t1 = 'q' ifTrue: [^ 17].
t1 = 'r' ifTrue: [^ 18].
t1 = 's' ifTrue: [^ 19].
t1 = 't' ifTrue: [^ 20].
t1 = 'u' ifTrue: [^ 21].
t1 = 'v' ifTrue: [^ 22].
t1 = 'w' ifTrue: [^ 23].
t1 = 'x' ifTrue: [^ 24].
t1 = 'y' ifTrue: [^ 25].
t1 = 'z' ifTrue: [^ 26].

Scratch just needs

Code:

| t1 |
t1 _ ''.

at the top. The ascii one would be good to add too.

No, Scratch doesn't need that at all.  That's how you define variables, but t1 is an argument--it needs to be in the selector at the top, such as "letterToNumber: t1".

Offline

 

#3011 2012-07-10 10:25:54

Randomno
Scratcher
Registered: 2012-06-04
Posts: 39

Re: ITopic: Welcome to your local block library!

Greenatic wrote:

Randomno wrote:

And with that, I'd like to submit this code to the block library (Scratch and Panther):

Code:

t1 = 'a' ifTrue: [^ 1].
t1 = 'b' ifTrue: [^ 2].
t1 = 'c' ifTrue: [^ 3].
t1 = 'd' ifTrue: [^ 4].
t1 = 'e' ifTrue: [^ 5].
t1 = 'f' ifTrue: [^ 6].
t1 = 'g' ifTrue: [^ 7].
t1 = 'h' ifTrue: [^ 8].
t1 = 'i' ifTrue: [^ 9].
t1 = 'j' ifTrue: [^ 10].
t1 = 'k' ifTrue: [^ 11].
t1 = 'l' ifTrue: [^ 12].
t1 = 'm' ifTrue: [^ 13].
t1 = 'n' ifTrue: [^ 14].
t1 = 'o' ifTrue: [^ 15].
t1 = 'p' ifTrue: [^ 16].
t1 = 'q' ifTrue: [^ 17].
t1 = 'r' ifTrue: [^ 18].
t1 = 's' ifTrue: [^ 19].
t1 = 't' ifTrue: [^ 20].
t1 = 'u' ifTrue: [^ 21].
t1 = 'v' ifTrue: [^ 22].
t1 = 'w' ifTrue: [^ 23].
t1 = 'x' ifTrue: [^ 24].
t1 = 'y' ifTrue: [^ 25].
t1 = 'z' ifTrue: [^ 26].

Scratch just needs

Code:

| t1 |
t1 _ ''.

at the top. The ascii one would be good to add too.

No, Scratch doesn't need that at all.  That's how you define variables, but t1 is an argument--it needs to be in the selector at the top, such as "letterToNumber: t1".

neutral  That's what Panther gave me when I viewed the code.


http://img209.imageshack.us/img209/5524/randomno.png
I do stuff with stuff. I also stuff stuff.

Offline

 

#3012 2012-07-10 10:38:10

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: ITopic: Welcome to your local block library!

Randomno wrote:

Greenatic wrote:

Randomno wrote:

And with that, I'd like to submit this code to the block library (Scratch and Panther):

Code:

t1 = 'a' ifTrue: [^ 1].
t1 = 'b' ifTrue: [^ 2].
t1 = 'c' ifTrue: [^ 3].
t1 = 'd' ifTrue: [^ 4].
t1 = 'e' ifTrue: [^ 5].
t1 = 'f' ifTrue: [^ 6].
t1 = 'g' ifTrue: [^ 7].
t1 = 'h' ifTrue: [^ 8].
t1 = 'i' ifTrue: [^ 9].
t1 = 'j' ifTrue: [^ 10].
t1 = 'k' ifTrue: [^ 11].
t1 = 'l' ifTrue: [^ 12].
t1 = 'm' ifTrue: [^ 13].
t1 = 'n' ifTrue: [^ 14].
t1 = 'o' ifTrue: [^ 15].
t1 = 'p' ifTrue: [^ 16].
t1 = 'q' ifTrue: [^ 17].
t1 = 'r' ifTrue: [^ 18].
t1 = 's' ifTrue: [^ 19].
t1 = 't' ifTrue: [^ 20].
t1 = 'u' ifTrue: [^ 21].
t1 = 'v' ifTrue: [^ 22].
t1 = 'w' ifTrue: [^ 23].
t1 = 'x' ifTrue: [^ 24].
t1 = 'y' ifTrue: [^ 25].
t1 = 'z' ifTrue: [^ 26].

Scratch just needs

Code:

| t1 |
t1 _ ''.

at the top. The ascii one would be good to add too.

No, Scratch doesn't need that at all.  That's how you define variables, but t1 is an argument--it needs to be in the selector at the top, such as "letterToNumber: t1".

neutral  That's what Panther gave me when I viewed the code.

Well panther creates that because it uses the compiler, probably. But that is not the case in scratch. Just trust Greenatic.
example:
Scratch

Code:

#('add %n and %n' #r #add:and:)

Code:

add: t1 and: t2
^ t1 + t2

Panther

Code:

add $Number$ and $Number$

the first argument is paired up with t1 and the second with t2

Code:

^ t1 + t2

The differences is there is no selector because selectors are only used to call methods. And this is NOT a method, unlike in Scratch

Offline

 

#3013 2012-07-10 10:46:13

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: ITopic: Welcome to your local block library!

I need help - could someone make me a Panther block for making a dialog show up with a question in, and instead of the title being ? can it be somthing that you tell the block to set the title to, like this:

Code:

show ask dialog named $String$

I'm back.
Maybe.

Offline

 

#3014 2012-07-10 12:22:59

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: ITopic: Welcome to your local block library!

Code:

ask $String$ title $String$

Code:

    | t3 |
    t3 _ StringDialog new
                withButtonsForYes: false
                no: false
                okay: true
                cancel: true;
             message: t1;
             title: t2;
initialAnswer: ''.
    ^ t3 getUserResponse

Offline

 

#3015 2012-07-11 16:08:02

SFollis
Scratcher
Registered: 2012-03-04
Posts: 76

Re: ITopic: Welcome to your local block library!

how do you create the scratch blocks? because i want the clone me block and record hide mouse cursor etc.

i mean like where to put the text if anyone is wondering

Last edited by SFollis (2012-07-14 11:22:42)


http://blocks.scratchr.org/API.php?user=SFollis&action=projects&type=newest&return=image&num=1 is a picture of my project http://blocks.scratchr.org/API.php?user=SFollis&action=projects&type=newest&return=text&num=1 which has http://blocks.scratchr.org/API.php?user=SFollis&action=projects&type=newest&return=views&num=1 views

Offline

 

#3016 2012-07-14 10:12:34

P110
Scratcher
Registered: 2011-04-12
Posts: 500+

Re: ITopic: Welcome to your local block library!

P110 wrote:

dreamod wrote:

P110 wrote:

hey do you think the code below could be used to POST projects to a mod website (aka mine) I know how to get the website to receive but could this send the contents of the project:

Code:

upload: url user: user password: password
    | t1 t2 t3 t4 t6 args |
    self stopAll.
    self world ifNotNil: [self world activeHand newKeyboardFocus: nil].
    self canonicalizeSoundsBits: nil saveOriginal: false.
    self canonicalizeImagesQuality: nil saveOriginal: false.
    t1 _ scriptsPane target.
    t2 _ scriptsPane tabPane currentTab.
    t3 _ viewerPane currentCategory.
    scriptsPane target: nil.
    workPane updateSpritesList.
    t4 _ workPane position.
    workPane delete; position: 0 @ 0.
    self updatePenPositions.
    ScriptableScratchMorph buildBlockSpecDictionary.
    workPane
        allMorphsDo: [:t7 | (t7 isKindOf: ScriptableScratchMorph)
                ifTrue: 
                    [t7 blocksBin
                        allMorphsDo: [:t8 | (t8 isKindOf: BlockMorph)
                                ifTrue: [t8 stop]].
                    t7 convertStacksToTuples]].

    t6 _ WriteStream on: (ByteArray new: 100000000).
    t6 nextPutAll: 'ScratchV02' asByteArray.
    self storeProjectInfoOn: t6.
    ObjStream new storeObj: workPane on: t6.

    workPane
        allMorphsDo: [:t7 | (t7 isKindOf: ScriptableScratchMorph)
                ifTrue: [t7 convertTuplesToStacks]].
    self addMorph: (workPane position: t4).
    t1 ifNil: [t1 _ workPane].
    t1 viewBlocksAndScripts.
    scriptsPane tabPane currentTab: t2.
    viewerPane currentCategory: t3.
    self updatePenPositions.

    args _ Dictionary new.
    args at: 'project' put: {projectName}.
    args at: 'data' put: (Array with: t6 contents asString).
    args at: 'user' put: {user}.
    args at: 'password' put: {password}.
    HTTPSocket httpPostDocument: url args: args

If so, anyone know how to script the dialog box, if I can't from the scratch one?

Thanks  smile

wow, that's nice. The dialog would be a piece of cake. I'll let you use the one for my block importer slightly modified.

Code:

'From MIT Squeak 0.9.4 (June 1, 2003) [No updates present.] on 4 July 2012 at 9:30:09 am'!
DialogBoxMorph subclass: #UploadDialogBoxMorph
    instanceVariableNames: 'userNameMorph target blockFile commentMorph passwordMorph '
    classVariableNames: 'URL '
    poolDictionaries: ''
    category: 'Scratch-UI-Dialogs'!


!UploadDialogBoxMorph methodsFor: 'accessing' stamp: 'dreamod 7/4/2012 09:29'!
getUserResponse

    "Wait for the user to type in and accept a string, then report that string. Answer the empty string if the user cancels the operation."

    "Details: This is invoked synchronously from the caller. In order to keep processing inputs and updating the screen while waiting for the user to respond, this method has its own version of the World's event loop."

    | w |
    self openInWorld.
    self centerOnScreen.
    w _ self world.
    w activeHand newKeyboardFocus: userNameMorph.
    done _ false.
    [done] whileFalse: [w doOneCycle].  "wait for user to press a button"
    response = #cancelled ifTrue: [^ self].
    target upload: URL user: userNameMorph contents asString password: passwordMorph contents asString.
    self delete.
    w doOneCycle.  "erase myself from the screen"

! !

!UploadDialogBoxMorph methodsFor: 'accessing' stamp: 'dreamod 7/4/2012 09:29'!
target
^ target
! !

!UploadDialogBoxMorph methodsFor: 'accessing' stamp: 'dreamod 7/4/2012 09:29'!
target: t1
^ target! !


!UploadDialogBoxMorph methodsFor: 'initialization' stamp: 'dreamod 7/4/2012 09:25'!
initialize
    super initialize.
    mainColumn addMorph: (Morph new extent: 5 @ 6;
         color: Color transparent).
    mainColumn addMorph: (Morph new extent: 5 @ 6;
         color: Color transparent);
     addMorph: (passwordMorph _ StringFieldMorph new client: self;
                 borderWidth: 2;
                 color: (Color
                        r: 211 / 255
                        g: 214 / 255
                        b: 216 / 255));
     addMorph: (Morph new extent: 5 @ 6;
         color: Color transparent).
    passwordMorph font: (ScratchFrameMorph getFont: #StringDialogTypeIn);
     width: 250.
    passwordMorph passwordMode: true.
    mainColumn addMorph: (Morph new extent: 5 @ 6;
         color: Color transparent);
     addMorph: (userNameMorph _ StringFieldMorph new client: self;
                 borderWidth: 2;
                 color: (Color
                        r: 211 / 255
                        g: 214 / 255
                        b: 216 / 255));
     addMorph: (Morph new extent: 5 @ 6;
         color: Color transparent).
    userNameMorph font: (ScratchFrameMorph getFont: #StringDialogTypeIn);
     width: 250.
    tabFields add: userNameMorph.
    tabFields add: passwordMorph.
    self message: 'Enter username and password'.
    self title: 'Upload Project to: ' , URL asString.
    self withButtonsForYes: false no: false okay: true cancel: true! !
!UTF8 methodsFor: 'converting'!
asString
    | t2 |
    t2 _ ''.
    self do: [:t1 | t2 _ t2 , t1 asString].
    ^ t2! !

Call it from ScratchFrameMorph like this:

Code:

UploadDialogBoxMorph new target: self; getUserResponse

The dialog will then call the method you made to the instance of ScratchFrameMorph defined once you're done filling in the form.

Wait, is that the actual dialog box code? Thanks!  big_smile

So, if I add that all to scratchFrameMorph it should all work?

This doesn't work for some reason,
It turns:

Code:

DialogBoxMorph subclass: #UploadDialogBoxMorph

Into this:

Code:

DialogBoxMorph  Nothing more expected ->subclass:#UploadDialogBoxMorph

Any ideas??

Quick note, I'm using the scratch source code, so I don't have the original dialog or upload code

Last edited by P110 (2012-07-14 10:14:06)


Me live on 2.0 now  sad

Offline

 

#3017 2012-07-14 11:07:50

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: ITopic: Welcome to your local block library!

You must copy the text but dont accept. Then you right click it and file it in. "file in"

Offline

 

#3018 2012-07-14 12:48:57

P110
Scratcher
Registered: 2011-04-12
Posts: 500+

Re: ITopic: Welcome to your local block library!

dreamod wrote:

You must copy the text but dont accept. Then you right click it and file it in. "file in"

Ah, I hadn't used file in before, I just though you meant add, (accept)

EDIT: I need to file in my code as well? It won't let me...

Last edited by P110 (2012-07-14 13:28:18)


Me live on 2.0 now  sad

Offline

 

#3019 2012-07-18 14:36:26

gooeygoo
Scratcher
Registered: 2012-05-07
Posts: 82

Re: ITopic: Welcome to your local block library!

Can I share my idea?


Play meh games, dont beh shy!!!
http://scratch.mit.edu/users/gooeygoo

Offline

 

#3020 2012-07-18 15:11:40

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: ITopic: Welcome to your local block library!

gooeygoo wrote:

Can I share my idea?

Of course!   smile

Offline

 

#3021 2012-07-18 18:34:03

gooeygoo
Scratcher
Registered: 2012-05-07
Posts: 82

Re: ITopic: Welcome to your local block library!

When gf clicked
go to [1:16] of sound [1]
Wait until <(sound)=[6:21]>
Go to [1:16] of sound [1]
The sound one is allowed you to go to the section of the song, and you don't need to wait!

Last edited by gooeygoo (2012-07-18 18:35:24)


Play meh games, dont beh shy!!!
http://scratch.mit.edu/users/gooeygoo

Offline

 

#3022 2012-07-18 22:01:57

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: ITopic: Welcome to your local block library!

gooeygoo wrote:

When gf clicked
go to [1:16] of sound [1]
Wait until <(sound)=[6:21]>
Go to [1:16] of sound [1]
The sound one is allowed you to go to the section of the song, and you don't need to wait!

Oh, you mean a block like this?

play from (60) seconds into [song  v]
So it starts a certain number of seconds into the song, and continues playing?  I can make that easily if that's what you want, but not tonight.  Maybe tomorrow.   smile

Offline

 

#3023 2012-07-19 00:50:01

chanmanpartyman
Scratcher
Registered: 2011-05-30
Posts: 500+

Re: ITopic: Welcome to your local block library!

I'd like to improve upon Greenatic's

move (10) steps towards [Sprite1 v]
block.

Code:

Move: t1 Towards: t2 
    self pointToX: t2 xpos y: t2 ypos.
    self forward: t1

Much more simplified.

Last edited by chanmanpartyman (2012-07-19 00:50:30)

Offline

 

#3024 2012-07-19 10:23:48

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: ITopic: Welcome to your local block library!

chanmanpartyman wrote:

I'd like to improve upon Greenatic's

move (10) steps towards [Sprite1 v]
block.

Code:

Move: t1 Towards: t2 
    self pointToX: t2 xpos y: t2 ypos.
    self forward: t1

Much more simplified.

But the point with that block was to not use rotation. So this block is pointless

Offline

 

#3025 2012-07-19 12:33:03

gooeygoo
Scratcher
Registered: 2012-05-07
Posts: 82

Re: ITopic: Welcome to your local block library!

Greenatic wrote:

gooeygoo wrote:

When gf clicked
go to [1:16] of sound [1]
Wait until <(sound)=[6:21]>
Go to [1:16] of sound [1]
The sound one is allowed you to go to the section of the song, and you don't need to wait!

Oh, you mean a block like this?

play from (60) seconds into [song  v]
So it starts a certain number of seconds into the song, and continues playing?  I can make that easily if that's what you want, but not tonight.  Maybe tomorrow.   smile

Thanks! That works, but If it was this, it would go directly to that part of the song

when gf clicked
Forever
play ( ) of song [Larries Lement v]
Wait until <<sound> = [6:21]>
go back to ( ) of song [Larries Lement v]

Last edited by gooeygoo (2012-07-19 12:35:40)


Play meh games, dont beh shy!!!
http://scratch.mit.edu/users/gooeygoo

Offline

 

Board footer