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

#3376 2010-07-08 20:06:05

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Panther development thread

Here:

Code:

| arr |
arr := Dictionary newFrom: {'0000' -> '0'. '0001' -> '1'. '0010' -> '2'. '0011' -> '3'. '0100' -> '4'. '0101' -> '5'. '0110' -> '6'. '0111' -> '7'. '1000' -> '8'. '1001' -> '9'. '1010' -> 'A'. '1011' -> 'B'. '1100' -> 'C'. '1101' -> 'D'. '1110' -> 'E'. '1111' -> 'F'}.
^ (arr at: (t1 asString copyFrom: 1 to: 4)), (arr at: (t1 asString copyFrom: 5 to:8)), (arr at: (t1 asString copyFrom: 9 to: 12)), (arr at: (t1 asString copyFrom: 13 to: 16)), (arr at: (t1 asString copyFrom: 17 to: 20)), (arr at: (t1 asString copyFrom: 21 to: 24)).

Took me a while, I kept getting errors when my Dictionary turned into a String somehow...

EDIT: Oh no, the dreaded 46th page! (it's probably like 120 for other people)

Last edited by nXIII (2010-07-08 20:06:41)


nXIII

Offline

 

#3377 2010-07-08 20:32:18

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Panther development thread

nXIII wrote:

Here:

Code:

| arr |
arr := Dictionary newFrom: {'0000' -> '0'. '0001' -> '1'. '0010' -> '2'. '0011' -> '3'. '0100' -> '4'. '0101' -> '5'. '0110' -> '6'. '0111' -> '7'. '1000' -> '8'. '1001' -> '9'. '1010' -> 'A'. '1011' -> 'B'. '1100' -> 'C'. '1101' -> 'D'. '1110' -> 'E'. '1111' -> 'F'}.
^ (arr at: (t1 asString copyFrom: 1 to: 4)), (arr at: (t1 asString copyFrom: 5 to:8)), (arr at: (t1 asString copyFrom: 9 to: 12)), (arr at: (t1 asString copyFrom: 13 to: 16)), (arr at: (t1 asString copyFrom: 17 to: 20)), (arr at: (t1 asString copyFrom: 21 to: 24)).

Took me a while, I kept getting errors when my Dictionary turned into a String somehow...

EDIT: Oh no, the dreaded 46th page! (it's probably like 120 for other people)

Thanks! Somehow I knew you would come up with it...


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#3378 2010-07-08 20:55:32

Jakey22
Scratcher
Registered: 2008-12-28
Posts: 72

Re: Panther development thread

Is there a way to make panther case sensitive?
I also am having this problem:
input = 05 - what panther recognizes: 5

It removes zeros if they are before a number. I'm making a decoder/encoder and it requires zeros to be used before numbers, and for panther to be case sensitive. Is there any way to impliment these features?


http://www.imagebookers.com/gallery/d/2561-1/ubuntu-wallpaper.png http://bullylug.org/linux-penguin.jpg
My website       PENGUINS!!!!!!!!!!!!!!!!!!!!! randomness.

Offline

 

#3379 2010-07-08 21:37:58

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Panther development thread

Jakey22 wrote:

Is there a way to make panther case sensitive?
I also am having this problem:
input = 05 - what panther recognizes: 5

It removes zeros if they are before a number. I'm making a decoder/encoder and it requires zeros to be used before numbers, and for panther to be case sensitive. Is there any way to impliment these features?

For the case sensitive part, go into CYOB, make a block called 'shift pressed?' and make it a boolean. For the code use this:

Sensor shiftPressed ifTrue: [^ true].
^ false

and for the 0's before numbers, you can't do it. Squeak automatically takes away 0's before numbers.


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#3380 2010-07-08 22:08:50

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Panther development thread

ScratchReallyROCKS wrote:

Jakey22 wrote:

Is there a way to make panther case sensitive?
I also am having this problem:
input = 05 - what panther recognizes: 5

It removes zeros if they are before a number. I'm making a decoder/encoder and it requires zeros to be used before numbers, and for panther to be case sensitive. Is there any way to impliment these features?

For the case sensitive part, go into CYOB, make a block called 'shift pressed?' and make it a boolean. For the code use this:

Sensor shiftPressed ifTrue: [^ true].
^ false

and for the 0's before numbers, you can't do it. Squeak automatically takes away 0's before numbers.

^ Sensor shiftKeyPressed.


nXIII

Offline

 

#3381 2010-07-08 22:15:39

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Panther development thread

nXIII wrote:

ScratchReallyROCKS wrote:

Jakey22 wrote:

Is there a way to make panther case sensitive?
I also am having this problem:
input = 05 - what panther recognizes: 5

It removes zeros if they are before a number. I'm making a decoder/encoder and it requires zeros to be used before numbers, and for panther to be case sensitive. Is there any way to impliment these features?

For the case sensitive part, go into CYOB, make a block called 'shift pressed?' and make it a boolean. For the code use this:

Sensor shiftPressed ifTrue: [^ true].
^ false

and for the 0's before numbers, you can't do it. Squeak automatically takes away 0's before numbers.

^ Sensor shiftKeyPressed.

actually it's shiftPressed, not shiftKeyPressed, but other than that, this is SO much better than mine because its SO much shorter.


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#3382 2010-07-08 22:17:13

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Panther development thread

ScratchReallyROCKS wrote:

nXIII wrote:

ScratchReallyROCKS wrote:

For the case sensitive part, go into CYOB, make a block called 'shift pressed?' and make it a boolean. For the code use this:

Sensor shiftPressed ifTrue: [^ true].
^ false

and for the 0's before numbers, you can't do it. Squeak automatically takes away 0's before numbers.

^ Sensor shiftKeyPressed.

actually it's shiftPressed, not shiftKeyPressed, but other than that, this is SO much better than mine because its SO much shorter.

Ah. From memory, you see...

Last edited by nXIII (2010-07-08 22:17:22)


nXIII

Offline

 

#3383 2010-07-08 22:25:28

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Panther development thread

When is panther 1.1 going to be released?


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#3384 2010-07-08 23:05:13

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: Panther development thread

ScratchReallyROCKS wrote:

can someone tell me what's wrong with this script? (I made it in CYOB and it's supposed to convert 24 bit binary numbers to hexadecimal values.)

A binary number is not a string of characters.  You can look on it as a string of bits, but that's not very helpful in this situation -- you really just want to think of it as a number, and do arithmetic on it, as opposed to string operations.

So.  Take your binary number, call it num.  Then

    <num> MOD <16>

is the value of the four rightmost bits of the number.  That value is itself a number, between 0 and 15.  You can use it to index into the string "0123456789abcdef" to find the character that represents the rightmost four bits.

So, that's the rightmost character.  What about the other characters?  Well, compute the value

    ( (<num> - (<num> MOD <16>) )  / 16 )

The dividend is divisible by 16, so the quotient is an integer.  You can do the same trick with this smaller number to find the next-to-rightmost character, etc.

This is a recursive procedure.  I am refraining from writing it in BYOB so the Panther people don't yell at me.  smile   You can write it in Smalltalk, too.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#3385 2010-07-09 01:52:13

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Panther development thread

ScratchReallyROCKS wrote:

johnnydean1 wrote:

I remade all of that and it works:

Code:

|length n1 n2 n3 n4 n5 n6 num hex x1 m1 c1 h1|
n1_ 0000.
n2_ 0000.
n3_ 0000.
n4_ 0000.
n5_ 0000.
n6_ 0000.

length_ self stringLength: (t1).
length >  23
ifTrue: [
n1_ self letters: (21) through: (24) of: (t1).
n1_ n1 asString.
].
length > 19
ifTrue: [
n2_ self letters: (17) through: (20) of: (t1).
n2_ n2 asString.
].

length > 15
ifTrue: [
n3_ self letters: (13) through: (16) of: (t1).
n3_ n3 asString.
].

length > 11
ifTrue: [
n4_ self letters: (9) through: (12) of: (t1).
n4_ n4 asString.
].

length > 7
ifTrue: [
n5_ self letters: (5) through: (8) of: (t1).
n5_ n5 asString.
].

length > 3
ifTrue: [
n6_ self letters: (1) through: (4) of: (t1).
n6_ n6 asString.
].


x1_ self letter: (4) of: (n1).
x1_ x1 asNumber.
x1_ x1 * 1.
c1_ self letter: (3) of: (n1).
c1_ c1 asNumber.
c1_ c1 * 2.
m1_ self letter: (2) of: (n1).
m1_ m1 asNumber.
m1_ m1 * 4.
h1_ self letter: (1) of: (n1).
h1_ h1 asNumber.
h1_ h1 * 8.

n1_ x1 + c1.
n1_ n1 + m1.
n1_ n1 + h1.




x1_ self letter: (4) of: (n2).
x1_ x1 asNumber.
x1_ x1 * 1.
c1_ self letter: (3) of: (n2).
c1_ c1 asNumber.
c1_ c1 * 2.
m1_ self letter: (2) of: (n2).
m1_ m1 asNumber.
m1_ m1 * 4.
h1_ self letter: (1) of: (n2).
h1_ h1 asNumber.
h1_ h1 * 8.

n2_ x1 + c1.
n2_ n2 + m1.
n2_ n2 + h1.


x1_ self letter: (4) of: (n3).
x1_ x1 asNumber.
x1_ x1 * 1.
c1_ self letter: (3) of: (n3).
c1_ c1 asNumber.
c1_ c1 * 2.
m1_ self letter: (2) of: (n3).
m1_ m1 asNumber.
m1_ m1 * 4.
h1_ self letter: (1) of: (n3).
h1_ h1 asNumber.
h1_ h1 * 8.

n3_ x1 + c1.
n3_ n3 + m1.
n3_ n3 + h1.


x1_ self letter: (4) of: (n4).
x1_ x1 asNumber.
x1_ x1 * 1.
c1_ self letter: (3) of: (n4).
c1_ c1 asNumber.
c1_ c1 * 2.
m1_ self letter: (2) of: (n4).
m1_ m1 asNumber.
m1_ m1 * 4.
h1_ self letter: (1) of: (n4).
h1_ h1 asNumber.
h1_ h1 * 8.

n4_ x1 + c1.
n4_ n4 + m1.
n4_ n4 + h1.

x1_ self letter: (4) of: (n5).
x1_ x1 asNumber.
x1_ x1 * 1.
c1_ self letter: (3) of: (n5).
c1_ c1 asNumber.
c1_ c1 * 2.
m1_ self letter: (2) of: (n5).
m1_ m1 asNumber.
m1_ m1 * 4.
h1_ self letter: (1) of: (n5).
h1_ h1 asNumber.
h1_ h1 * 8.

n5_ x1 + c1.
n5_ n5 + m1.
n5_ n5 + h1.


x1_ self letter: (4) of: (n6).
x1_ x1 asNumber.
x1_ x1 * 1.
c1_ self letter: (3) of: (n6).
c1_ c1 asNumber.
c1_ c1 * 2.
m1_ self letter: (2) of: (n6).
m1_ m1 asNumber.
m1_ m1 * 4.
h1_ self letter: (1) of: (n6).
h1_ h1 asNumber.
h1_ h1 * 8.

n6_ x1 + c1.
n6_ n6 + m1.
n6_ n6 + h1.

num_ ''.
num_ self concatenate: (num) with: (n1).

num_ self concatenate: (num) with: (n2). 

num_ self concatenate: (num) with: (n3). 

num_ self concatenate: (num) with: (n4). 

num_ self concatenate: (num) with: (n5). 

num_ self concatenate: (num) with: (n6).

^ num

You owe me big time this took me about 1 hour!

It may have taken you an hour, but it's still not what I want. I need a code that converts a a 24 bit binary number into a hexadecimal value. Use this to see how binary and hexadecimal numbers line up:

Binary    |    Hexadecimal
0000       |    0
0001       |    1
0010       |    2
0011       |    3
0100       |    4
0101       |    5
0110       |    6
0111       |    7
1000       |    8
1001       |    9
1010       |    A
1011       |    B
1100       |    C
1101       |    D
1110       |    E
1111       |    F

so that means that hexadecimal FFFFFF or white, would be 111111111111111111111111 in binary, and hexadecimal 0000FF or blue, would be 000000000000000011111111 in binary.

Well the code you put before is the same as that when it works.


You can now reach me on Twitter @johnnydean1_

Offline

 

#3386 2010-07-09 09:54:06

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Panther development thread

johnnydean1 wrote:

ScratchReallyROCKS wrote:

johnnydean1 wrote:

I remade all of that and it works:

Code:

|length n1 n2 n3 n4 n5 n6 num hex x1 m1 c1 h1|
n1_ 0000.
n2_ 0000.
n3_ 0000.
n4_ 0000.
n5_ 0000.
n6_ 0000.

length_ self stringLength: (t1).
length >  23
ifTrue: [
n1_ self letters: (21) through: (24) of: (t1).
n1_ n1 asString.
].
length > 19
ifTrue: [
n2_ self letters: (17) through: (20) of: (t1).
n2_ n2 asString.
].

length > 15
ifTrue: [
n3_ self letters: (13) through: (16) of: (t1).
n3_ n3 asString.
].

length > 11
ifTrue: [
n4_ self letters: (9) through: (12) of: (t1).
n4_ n4 asString.
].

length > 7
ifTrue: [
n5_ self letters: (5) through: (8) of: (t1).
n5_ n5 asString.
].

length > 3
ifTrue: [
n6_ self letters: (1) through: (4) of: (t1).
n6_ n6 asString.
].


x1_ self letter: (4) of: (n1).
x1_ x1 asNumber.
x1_ x1 * 1.
c1_ self letter: (3) of: (n1).
c1_ c1 asNumber.
c1_ c1 * 2.
m1_ self letter: (2) of: (n1).
m1_ m1 asNumber.
m1_ m1 * 4.
h1_ self letter: (1) of: (n1).
h1_ h1 asNumber.
h1_ h1 * 8.

n1_ x1 + c1.
n1_ n1 + m1.
n1_ n1 + h1.




x1_ self letter: (4) of: (n2).
x1_ x1 asNumber.
x1_ x1 * 1.
c1_ self letter: (3) of: (n2).
c1_ c1 asNumber.
c1_ c1 * 2.
m1_ self letter: (2) of: (n2).
m1_ m1 asNumber.
m1_ m1 * 4.
h1_ self letter: (1) of: (n2).
h1_ h1 asNumber.
h1_ h1 * 8.

n2_ x1 + c1.
n2_ n2 + m1.
n2_ n2 + h1.


x1_ self letter: (4) of: (n3).
x1_ x1 asNumber.
x1_ x1 * 1.
c1_ self letter: (3) of: (n3).
c1_ c1 asNumber.
c1_ c1 * 2.
m1_ self letter: (2) of: (n3).
m1_ m1 asNumber.
m1_ m1 * 4.
h1_ self letter: (1) of: (n3).
h1_ h1 asNumber.
h1_ h1 * 8.

n3_ x1 + c1.
n3_ n3 + m1.
n3_ n3 + h1.


x1_ self letter: (4) of: (n4).
x1_ x1 asNumber.
x1_ x1 * 1.
c1_ self letter: (3) of: (n4).
c1_ c1 asNumber.
c1_ c1 * 2.
m1_ self letter: (2) of: (n4).
m1_ m1 asNumber.
m1_ m1 * 4.
h1_ self letter: (1) of: (n4).
h1_ h1 asNumber.
h1_ h1 * 8.

n4_ x1 + c1.
n4_ n4 + m1.
n4_ n4 + h1.

x1_ self letter: (4) of: (n5).
x1_ x1 asNumber.
x1_ x1 * 1.
c1_ self letter: (3) of: (n5).
c1_ c1 asNumber.
c1_ c1 * 2.
m1_ self letter: (2) of: (n5).
m1_ m1 asNumber.
m1_ m1 * 4.
h1_ self letter: (1) of: (n5).
h1_ h1 asNumber.
h1_ h1 * 8.

n5_ x1 + c1.
n5_ n5 + m1.
n5_ n5 + h1.


x1_ self letter: (4) of: (n6).
x1_ x1 asNumber.
x1_ x1 * 1.
c1_ self letter: (3) of: (n6).
c1_ c1 asNumber.
c1_ c1 * 2.
m1_ self letter: (2) of: (n6).
m1_ m1 asNumber.
m1_ m1 * 4.
h1_ self letter: (1) of: (n6).
h1_ h1 asNumber.
h1_ h1 * 8.

n6_ x1 + c1.
n6_ n6 + m1.
n6_ n6 + h1.

num_ ''.
num_ self concatenate: (num) with: (n1).

num_ self concatenate: (num) with: (n2). 

num_ self concatenate: (num) with: (n3). 

num_ self concatenate: (num) with: (n4). 

num_ self concatenate: (num) with: (n5). 

num_ self concatenate: (num) with: (n6).

^ num

You owe me big time this took me about 1 hour!

It may have taken you an hour, but it's still not what I want. I need a code that converts a a 24 bit binary number into a hexadecimal value. Use this to see how binary and hexadecimal numbers line up:

Binary    |    Hexadecimal
0000       |    0
0001       |    1
0010       |    2
0011       |    3
0100       |    4
0101       |    5
0110       |    6
0111       |    7
1000       |    8
1001       |    9
1010       |    A
1011       |    B
1100       |    C
1101       |    D
1110       |    E
1111       |    F

so that means that hexadecimal FFFFFF or white, would be 111111111111111111111111 in binary, and hexadecimal 0000FF or blue, would be 000000000000000011111111 in binary.

Well the code you put before is the same as that when it works.

Yeah but the code I put before wasn't the whole thing.


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#3387 2010-07-09 10:45:54

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Panther development thread

So post the whole thing!


You can now reach me on Twitter @johnnydean1_

Offline

 

#3388 2010-07-09 10:52:28

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Panther development thread

johnnydean1 wrote:

So post the whole thing!

I don't need to anymore! nXIII gave me a code that works.


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#3389 2010-07-09 11:06:23

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Panther development thread

Oh man I just did this:

Code:

|length n1 n2 n3 n4 n5 n6 num x1 c1 input|
input_ t1.
input_ input asString.

n1_ 0000.
n2_ 0000.
n3_ 0000.
n4_ 0000.
n5_ 0000.
n6_ 0000.

length_ self stringLength: (input).
length >  23
ifTrue: [
n1_ self letters: (21) through: (24) of: (input).
n1_ n1 asNumber.
].
length > 19
ifTrue: [
n2_ self letters: (17) through: (20) of: (input).
n2_ n2 asNumber.
].

length > 15
ifTrue: [
n3_ self letters: (13) through: (16) of: (input).
n3_ n3 asNumber.
].

length > 11
ifTrue: [
n4_ self letters: (9) through: (12) of: (input).
n4_ n4 asNumber.
].

length > 7
ifTrue: [
n5_ self letters: (5) through: (8) of: (input).
n5_ n5 asNumber.
].

length > 3
ifTrue: [
n6_ self letters: (1) through: (4) of: (input).
n6_ n6 asNumber.
].

c1_ n1.

c1 = 0000
ifTrue: [
x1_ 0.
].
c1 = 0001
ifTrue: [
x1_ 1.
].
c1 = 0010
ifTrue: [
x1_ 2.
].
c1 = 0011
ifTrue: [
x1_ 3.
].
c1 = 0100
ifTrue: [
x1_ 4.
].
c1 = 0101
ifTrue: [
x1_ 5.
].
c1 = 0110
ifTrue: [
x1_ 6.
].
c1 = 0111
ifTrue: [
x1_ 7.
].
c1 = 1000
ifTrue: [
x1_ 8.
].
c1 = 1001
ifTrue: [
x1_ 9.
].
c1 = 1010
ifTrue: [
x1_ 'A'.
].
c1 = 1011
ifTrue: [
x1_ 'B'.
].
c1 = 1100
ifTrue: [
x1_ 'C'.
].
c1 = 1101
ifTrue: [
x1_ 'D'.
].
c1 = 1110
ifTrue: [
x1_ 'E'.
].
c1 = 1111
ifTrue: [
x1_ 'F'.
].
n1_ x1.


c1_ n2.

c1 = 0000
ifTrue: [
x1_ 0.
].
c1 = 0001
ifTrue: [
x1_ 1.
].
c1 = 0010
ifTrue: [
x1_ 2.
].
c1 = 0011
ifTrue: [
x1_ 3.
].
c1 = 0100
ifTrue: [
x1_ 4.
].
c1 = 0101
ifTrue: [
x1_ 5.
].
c1 = 0110
ifTrue: [
x1_ 6.
].
c1 = 0111
ifTrue: [
x1_ 7.
].
c1 = 1000
ifTrue: [
x1_ 8.
].
c1 = 1001
ifTrue: [
x1_ 9.
].
c1 = 1010
ifTrue: [
x1_ 'A'.
].
c1 = 1011
ifTrue: [
x1_ 'B'.
].
c1 = 1100
ifTrue: [
x1_ 'C'.
].
c1 = 1101
ifTrue: [
x1_ 'D'.
].
c1 = 1110
ifTrue: [
x1_ 'E'.
].
c1 = 1111
ifTrue: [
x1_ 'F'.
].
n2_ x1.

c1_ n3.

c1 = 0000
ifTrue: [
x1_ 0.
].
c1 = 0001
ifTrue: [
x1_ 1.
].
c1 = 0010
ifTrue: [
x1_ 2.
].
c1 = 0011
ifTrue: [
x1_ 3.
].
c1 = 0100
ifTrue: [
x1_ 4.
].
c1 = 0101
ifTrue: [
x1_ 5.
].
c1 = 0110
ifTrue: [
x1_ 6.
].
c1 = 0111
ifTrue: [
x1_ 7.
].
c1 = 1000
ifTrue: [
x1_ 8.
].
c1 = 1001
ifTrue: [
x1_ 9.
].
c1 = 1010
ifTrue: [
x1_ 'A'.
].
c1 = 1011
ifTrue: [
x1_ 'B'.
].
c1 = 1100
ifTrue: [
x1_ 'C'.
].
c1 = 1101
ifTrue: [
x1_ 'D'.
].
c1 = 1110
ifTrue: [
x1_ 'E'.
].
c1 = 1111
ifTrue: [
x1_ 'F'.
].
n3_ x1.



c1_ n4.

c1 = 0000
ifTrue: [
x1_ 0.
].
c1 = 0001
ifTrue: [
x1_ 1.
].
c1 = 0010
ifTrue: [
x1_ 2.
].
c1 = 0011
ifTrue: [
x1_ 3.
].
c1 = 0100
ifTrue: [
x1_ 4.
].
c1 = 0101
ifTrue: [
x1_ 5.
].
c1 = 0110
ifTrue: [
x1_ 6.
].
c1 = 0111
ifTrue: [
x1_ 7.
].
c1 = 1000
ifTrue: [
x1_ 8.
].
c1 = 1001
ifTrue: [
x1_ 9.
].
c1 = 1010
ifTrue: [
x1_ 'A'.
].
c1 = 1011
ifTrue: [
x1_ 'B'.
].
c1 = 1100
ifTrue: [
x1_ 'C'.
].
c1 = 1101
ifTrue: [
x1_ 'D'.
].
c1 = 1110
ifTrue: [
x1_ 'E'.
].
c1 = 1111
ifTrue: [
x1_ 'F'.
].
n4_ x1.


c1_ n5.

c1 = 0000
ifTrue: [
x1_ 0.
].
c1 = 0001
ifTrue: [
x1_ 1.
].
c1 = 0010
ifTrue: [
x1_ 2.
].
c1 = 0011
ifTrue: [
x1_ 3.
].
c1 = 0100
ifTrue: [
x1_ 4.
].
c1 = 0101
ifTrue: [
x1_ 5.
].
c1 = 0110
ifTrue: [
x1_ 6.
].
c1 = 0111
ifTrue: [
x1_ 7.
].
c1 = 1000
ifTrue: [
x1_ 8.
].
c1 = 1001
ifTrue: [
x1_ 9.
].
c1 = 1010
ifTrue: [
x1_ 'A'.
].
c1 = 1011
ifTrue: [
x1_ 'B'.
].
c1 = 1100
ifTrue: [
x1_ 'C'.
].
c1 = 1101
ifTrue: [
x1_ 'D'.
].
c1 = 1110
ifTrue: [
x1_ 'E'.
].
c1 = 1111
ifTrue: [
x1_ 'F'.
].
n5_ x1.


c1_ n6.

c1 = 0000
ifTrue: [
x1_ 0.
].
c1 = 0001
ifTrue: [
x1_ 1.
].
c1 = 0010
ifTrue: [
x1_ 2.
].
c1 = 0011
ifTrue: [
x1_ 3.
].
c1 = 0100
ifTrue: [
x1_ 4.
].
c1 = 0101
ifTrue: [
x1_ 5.
].
c1 = 0110
ifTrue: [
x1_ 6.
].
c1 = 0111
ifTrue: [
x1_ 7.
].
c1 = 1000
ifTrue: [
x1_ 8.
].
c1 = 1001
ifTrue: [
x1_ 9.
].
c1 = 1010
ifTrue: [
x1_ 'A'.
].
c1 = 1011
ifTrue: [
x1_ 'B'.
].
c1 = 1100
ifTrue: [
x1_ 'C'.
].
c1 = 1101
ifTrue: [
x1_ 'D'.
].
c1 = 1110
ifTrue: [
x1_ 'E'.
].
c1 = 1111
ifTrue: [
x1_ 'F'.
].
n6_ x1.
















num_ '#'.
num_ self concatenate: (num) with: (n1).

num_ self concatenate: (num) with: (n2). 

num_ self concatenate: (num) with: (n3). 

num_ self concatenate: (num) with: (n4). 

num_ self concatenate: (num) with: (n5). 

num_ self concatenate: (num) with: (n6).

^ num

You can now reach me on Twitter @johnnydean1_

Offline

 

#3390 2010-07-09 11:33:51

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Panther development thread

johnnydean1 wrote:

Oh man I just did this:

Code:

|length n1 n2 n3 n4 n5 n6 num x1 c1 input|
input_ t1.
input_ input asString.

n1_ 0000.
n2_ 0000.
n3_ 0000.
n4_ 0000.
n5_ 0000.
n6_ 0000.

length_ self stringLength: (input).
length >  23
ifTrue: [
n1_ self letters: (21) through: (24) of: (input).
n1_ n1 asNumber.
].
length > 19
ifTrue: [
n2_ self letters: (17) through: (20) of: (input).
n2_ n2 asNumber.
].

length > 15
ifTrue: [
n3_ self letters: (13) through: (16) of: (input).
n3_ n3 asNumber.
].

length > 11
ifTrue: [
n4_ self letters: (9) through: (12) of: (input).
n4_ n4 asNumber.
].

length > 7
ifTrue: [
n5_ self letters: (5) through: (8) of: (input).
n5_ n5 asNumber.
].

length > 3
ifTrue: [
n6_ self letters: (1) through: (4) of: (input).
n6_ n6 asNumber.
].

c1_ n1.

c1 = 0000
ifTrue: [
x1_ 0.
].
c1 = 0001
ifTrue: [
x1_ 1.
].
c1 = 0010
ifTrue: [
x1_ 2.
].
c1 = 0011
ifTrue: [
x1_ 3.
].
c1 = 0100
ifTrue: [
x1_ 4.
].
c1 = 0101
ifTrue: [
x1_ 5.
].
c1 = 0110
ifTrue: [
x1_ 6.
].
c1 = 0111
ifTrue: [
x1_ 7.
].
c1 = 1000
ifTrue: [
x1_ 8.
].
c1 = 1001
ifTrue: [
x1_ 9.
].
c1 = 1010
ifTrue: [
x1_ 'A'.
].
c1 = 1011
ifTrue: [
x1_ 'B'.
].
c1 = 1100
ifTrue: [
x1_ 'C'.
].
c1 = 1101
ifTrue: [
x1_ 'D'.
].
c1 = 1110
ifTrue: [
x1_ 'E'.
].
c1 = 1111
ifTrue: [
x1_ 'F'.
].
n1_ x1.


c1_ n2.

c1 = 0000
ifTrue: [
x1_ 0.
].
c1 = 0001
ifTrue: [
x1_ 1.
].
c1 = 0010
ifTrue: [
x1_ 2.
].
c1 = 0011
ifTrue: [
x1_ 3.
].
c1 = 0100
ifTrue: [
x1_ 4.
].
c1 = 0101
ifTrue: [
x1_ 5.
].
c1 = 0110
ifTrue: [
x1_ 6.
].
c1 = 0111
ifTrue: [
x1_ 7.
].
c1 = 1000
ifTrue: [
x1_ 8.
].
c1 = 1001
ifTrue: [
x1_ 9.
].
c1 = 1010
ifTrue: [
x1_ 'A'.
].
c1 = 1011
ifTrue: [
x1_ 'B'.
].
c1 = 1100
ifTrue: [
x1_ 'C'.
].
c1 = 1101
ifTrue: [
x1_ 'D'.
].
c1 = 1110
ifTrue: [
x1_ 'E'.
].
c1 = 1111
ifTrue: [
x1_ 'F'.
].
n2_ x1.

c1_ n3.

c1 = 0000
ifTrue: [
x1_ 0.
].
c1 = 0001
ifTrue: [
x1_ 1.
].
c1 = 0010
ifTrue: [
x1_ 2.
].
c1 = 0011
ifTrue: [
x1_ 3.
].
c1 = 0100
ifTrue: [
x1_ 4.
].
c1 = 0101
ifTrue: [
x1_ 5.
].
c1 = 0110
ifTrue: [
x1_ 6.
].
c1 = 0111
ifTrue: [
x1_ 7.
].
c1 = 1000
ifTrue: [
x1_ 8.
].
c1 = 1001
ifTrue: [
x1_ 9.
].
c1 = 1010
ifTrue: [
x1_ 'A'.
].
c1 = 1011
ifTrue: [
x1_ 'B'.
].
c1 = 1100
ifTrue: [
x1_ 'C'.
].
c1 = 1101
ifTrue: [
x1_ 'D'.
].
c1 = 1110
ifTrue: [
x1_ 'E'.
].
c1 = 1111
ifTrue: [
x1_ 'F'.
].
n3_ x1.



c1_ n4.

c1 = 0000
ifTrue: [
x1_ 0.
].
c1 = 0001
ifTrue: [
x1_ 1.
].
c1 = 0010
ifTrue: [
x1_ 2.
].
c1 = 0011
ifTrue: [
x1_ 3.
].
c1 = 0100
ifTrue: [
x1_ 4.
].
c1 = 0101
ifTrue: [
x1_ 5.
].
c1 = 0110
ifTrue: [
x1_ 6.
].
c1 = 0111
ifTrue: [
x1_ 7.
].
c1 = 1000
ifTrue: [
x1_ 8.
].
c1 = 1001
ifTrue: [
x1_ 9.
].
c1 = 1010
ifTrue: [
x1_ 'A'.
].
c1 = 1011
ifTrue: [
x1_ 'B'.
].
c1 = 1100
ifTrue: [
x1_ 'C'.
].
c1 = 1101
ifTrue: [
x1_ 'D'.
].
c1 = 1110
ifTrue: [
x1_ 'E'.
].
c1 = 1111
ifTrue: [
x1_ 'F'.
].
n4_ x1.


c1_ n5.

c1 = 0000
ifTrue: [
x1_ 0.
].
c1 = 0001
ifTrue: [
x1_ 1.
].
c1 = 0010
ifTrue: [
x1_ 2.
].
c1 = 0011
ifTrue: [
x1_ 3.
].
c1 = 0100
ifTrue: [
x1_ 4.
].
c1 = 0101
ifTrue: [
x1_ 5.
].
c1 = 0110
ifTrue: [
x1_ 6.
].
c1 = 0111
ifTrue: [
x1_ 7.
].
c1 = 1000
ifTrue: [
x1_ 8.
].
c1 = 1001
ifTrue: [
x1_ 9.
].
c1 = 1010
ifTrue: [
x1_ 'A'.
].
c1 = 1011
ifTrue: [
x1_ 'B'.
].
c1 = 1100
ifTrue: [
x1_ 'C'.
].
c1 = 1101
ifTrue: [
x1_ 'D'.
].
c1 = 1110
ifTrue: [
x1_ 'E'.
].
c1 = 1111
ifTrue: [
x1_ 'F'.
].
n5_ x1.


c1_ n6.

c1 = 0000
ifTrue: [
x1_ 0.
].
c1 = 0001
ifTrue: [
x1_ 1.
].
c1 = 0010
ifTrue: [
x1_ 2.
].
c1 = 0011
ifTrue: [
x1_ 3.
].
c1 = 0100
ifTrue: [
x1_ 4.
].
c1 = 0101
ifTrue: [
x1_ 5.
].
c1 = 0110
ifTrue: [
x1_ 6.
].
c1 = 0111
ifTrue: [
x1_ 7.
].
c1 = 1000
ifTrue: [
x1_ 8.
].
c1 = 1001
ifTrue: [
x1_ 9.
].
c1 = 1010
ifTrue: [
x1_ 'A'.
].
c1 = 1011
ifTrue: [
x1_ 'B'.
].
c1 = 1100
ifTrue: [
x1_ 'C'.
].
c1 = 1101
ifTrue: [
x1_ 'D'.
].
c1 = 1110
ifTrue: [
x1_ 'E'.
].
c1 = 1111
ifTrue: [
x1_ 'F'.
].
n6_ x1.
















num_ '#'.
num_ self concatenate: (num) with: (n1).

num_ self concatenate: (num) with: (n2). 

num_ self concatenate: (num) with: (n3). 

num_ self concatenate: (num) with: (n4). 

num_ self concatenate: (num) with: (n5). 

num_ self concatenate: (num) with: (n6).

^ num

That works too...

EDIT: You can't make recursive custom blocks in Panther, right?

Last edited by ScratchReallyROCKS (2010-07-09 11:39:14)


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#3391 2010-07-09 12:41:42

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: Panther development thread

ScratchReallyROCKS wrote:

You can't make recursive custom blocks in Panther, right?

I don't see why not -- Smalltalk is a real programming language, it allows recursion.

^ self foo x-1

or whatever.

EDIT:  I guess technically it's not the block that's recursive, but rather the underlying method.  So you could put a method named asHex in the Integer class and define it as (I'm guessing...)

self < 16
ifTrue: ^ '0123456789abcdef'[self].
ifFalse: ^ (self/16 floor asHex, '0123...def'[self mod 16])

Not being a Smalltalk programmer I just made up the notation for integer quotient, mod, and choosing a character from a string by index, but I'm pretty sure about the "^" part.  smile

Last edited by bharvey (2010-07-09 13:23:25)


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#3392 2010-07-09 18:03:31

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Panther development thread

I was thinking about recursive non-method procedures when I received your email, and it turns out (as I told you) there is a way to do this:

Code:

factorial := [:x |
    x = 0 ifTrue: [1] ifFalse: [
        x * (factorial value: x - 1)]].

factorial value: 3. "=> 6"
factorial value: 5. "=> 120"

coming soon (AKA when I figure it out  tongue ) are unnamed recursive procedures

Last edited by nXIII (2010-07-09 18:04:18)


nXIII

Offline

 

#3393 2010-07-09 20:07:33

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: Panther development thread

nXIII wrote:

I was thinking about recursive non-method procedures when I received your email, and it turns out (as I told you) there is a way to do this:

Code:

factorial := [:x |
    x = 0 ifTrue: [1] ifFalse: [
        x * (factorial value: x - 1)]].

factorial value: 3. "=> 6"
factorial value: 5. "=> 120"

coming soon (AKA when I figure it out  tongue ) are unnamed recursive procedures

Hey! Did you see that Billybob-Mario made an online squeak VM? Ever think of a panther one?


http://i46.tinypic.com/dw7zft.png

Offline

 

#3394 2010-07-09 22:35:44

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: Panther development thread

nXIII wrote:

coming soon (AKA when I figure it out  tongue ) are unnamed recursive procedures

You're an amazing programmer and I'm hesitant to tell you there's anything you can't do, but I think actually this is one of them.  You may well figure out how to have a recursive procedure without a global name, but there's no way a procedure can call itself without having a name for itself -- unless you just change the rules of discourse somehow so as to exclude from the term "name" a form of self-reference.

Figuring out how to write recursive procedures without a global naming mechanism is a key part of the Church numeral project on the BYOB web site.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#3395 2010-07-10 02:00:16

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: Panther development thread

When I show a Reporter block's stage monitor, it works fine - and then when I close it, I get this error thing from the System Browser. I can't show that stage monitor again until I do that stuff with a different Reporter block. My question: Will it be fixed in 1.1?  smile   smile   smile

Last edited by Jonathanpb (2010-07-10 02:00:35)


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#3396 2010-07-10 03:27:27

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Panther development thread

^ Yes


You can now reach me on Twitter @johnnydean1_

Offline

 

#3397 2010-07-10 05:50:11

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Panther development thread

Is the pitch block in 1.1?


You can now reach me on Twitter @johnnydean1_

Offline

 

#3398 2010-07-10 06:33:31

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Panther development thread

johnnydean1 wrote:

Is the pitch block in 1.1?

it might be.... production has slowed quite a bit at the moment.


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#3399 2010-07-10 07:54:48

paulpsicle
Scratcher
Registered: 2008-10-12
Posts: 100+

Re: Panther development thread

Code:

| t2 t3 |
(t1 = '') ifTrue:[^ false]
t2 _  self numFileLines: (t1) asString.
(t2 = '') ifTrue:[
    t3 _ FileStream newFileNamed: t1.
    t3 close
].

spec:
make file $String$
type:
-

when I run this, it just hangs. Why?


http://blocks.scratchr.org/API.php?user=paulpsicle&amp;action=onlineStatus&amp;online=http://fishery.dyndns.org/paulpsicle.png&amp;offline=http://fishery.dyndns.org/paulpsicle_o.png

Offline

 

#3400 2010-07-10 08:06:35

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Panther development thread

Jonathanpb wrote:

When I show a Reporter block's stage monitor, it works fine - and then when I close it, I get this error thing from the System Browser. I can't show that stage monitor again until I do that stuff with a different Reporter block. My question: Will it be fixed in 1.1?  smile   smile   smile

Im sure we're trying to fix it, its because nXIII edited the variables, you'll see if you reopen it in scratch (After renaming it .sb) you get this:
Before
http://img59.imageshack.us/img59/6888/panthervarblocks.gif
After
http://img21.imageshack.us/img21/3876/obseletevarblocks.gif

I know you're talking about the watchers, but they're quite similar cases, the work very different in panther, but scratch bllocks are converted to panther blocks when you load a scratch project. I'm sure nXIII is working on fixing them.


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

Board footer