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

#1 2011-11-29 21:01:21

Laternenpfahl
Scratcher
Registered: 2011-06-24
Posts: 1000+

Please help!

I need help for my upcoming project.

Please give me a script that decodes

Code:

set (letter) (num1),(num2)

into:

(letter)(num1)(num2)

Credit will be given.


http://i46.tinypic.com/6yd4c0.png

Offline

 

#2 2011-11-29 21:28:16

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

Re: Please help!

Are you going to actually have letters?  'set A 3,4' ?

If so, use this.  Store the 'set A 3,4' or whatever into a variable called string, and make two variables, var1 and var2.

Please note:
In line 2, that's an empty string.  In line 4, that's a single space.

set var1 to 1.
set var2 to ''.         
repeat (length of (string)) {
if <<(letter (var1) of (string)) = ' '> or <(letter (var1) of (string)) = ','> {
set var2 to (join (var2) (letter (var1) of (string)). }
change var1 by 1. }

At the end, the string 'A34' (for this example) should be stored in var2.

Last edited by Greenatic (2011-11-29 21:29:06)

Offline

 

#3 2011-11-29 21:37:15

Laternenpfahl
Scratcher
Registered: 2011-06-24
Posts: 1000+

Re: Please help!

Greenatic wrote:

Are you going to actually have letters?  'set A 3,4' ?

If so, use this.  Store the 'set A 3,4' or whatever into a variable called string, and make two variables, var1 and var2.

Please note:
In line 2, that's an empty string.  In line 4, that's a single space.

set var1 to 1.
set var2 to ''.         
repeat (length of (string)) {
if <<(letter (var1) of (string)) = ' '> or <(letter (var1) of (string)) = ','> {
set var2 to (join (var2) (letter (var1) of (string)). }
change var1 by 1. }

At the end, the string 'A34' (for this example) should be stored in var2.

The output must be 3 seperate variables.


http://i46.tinypic.com/6yd4c0.png

Offline

 

#4 2011-11-29 22:10:46

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Please help!

Code:

set [string] to (set A12)
set [var1] to (letter(5) of (string) )
set [var2] to (letter(6) of (string) )
set [var3] to (letter(7) of (string) )

http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#5 2011-11-29 22:12:38

Laternenpfahl
Scratcher
Registered: 2011-06-24
Posts: 1000+

Re: Please help!

MoreGamesNow wrote:

Code:

set [string] to (set A12)
set [var1] to (letter(5) of (string) )
set [var2] to (letter(6) of (string) )
set [var3] to (letter(7) of (string) )

No, the numbers can have a different length.


http://i46.tinypic.com/6yd4c0.png

Offline

 

#6 2011-11-29 22:18:57

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Please help!

Oh, my mistake.  I've got code to break up a string into array elements by a character:

Code:

set [i] to (0)
delete (all) of [list]
add () to [list]
repeat (length of variable)
{
     change [i] by (1)
     if(letter (i) of (variable) == [,] )
     {
          add () to [list]
     }
     else
     {
          replace item (last) of [list] with  (join ((item (last) of [list]) with (letter (i) of (variable)))
     }
}

With a little tinkering maybe?  Sorry, it's late and I can't help more, maybe tomorrow  hmm


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#7 2011-11-30 09:48:24

Laternenpfahl
Scratcher
Registered: 2011-06-24
Posts: 1000+

Re: Please help!

Bump


http://i46.tinypic.com/6yd4c0.png

Offline

 

#8 2011-11-30 20:06:22

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Please help!

Code:

set [string] to (set a40,30)
set [i] to (5)
delete (all) of [list]
add () to [list]
repeat (length of (string) )
{
     change [i] by (1)
     if (letter (i) of (string) = [,])
     {
          add [] to list
     }
     else
     {
          replace item (last) of [list] with ((join (item (last) of [list]) with (letter (i) of (string) ) ) )
     }
     
}

http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#9 2011-12-01 14:02:37

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

Re: Please help!

@MoreGamesNow
the site says My browser dosent support HTML5 Canvas when i click on the cube, Do you know why?


I'm back.
Maybe.

Offline

 

#10 2011-12-01 22:50:00

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Please help!

You're probably using Internet Explorer, which is one of the few (the only?) browser that doesn't support HTML5 canvas.  Actually, I've heard that it does support canvas, but it follows a totally different syntax.  Anyway, switch to Firefox or another browser, and it should work.


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

Board footer