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

#1 2009-01-24 21:34:36

Jello715
Scratcher
Registered: 2008-10-11
Posts: 95

List - to - variable

Is there anyway I can get numbers from a list to a variable without spaces?

For example, if my list looks like this:

[1] 3
[2] 7
[3] 6

can I set variable X to 376 WITHOUT SPACES?

Offline

 

#2 2009-01-24 21:40:44

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: List - to - variable

set variable x to 0
set variable i to length of list
set variable multiply to 1
repeat (length of your list)
change x by (item i of list*multiply)
change i by -1
set multiply to (multiply*10)


That should do it

Last edited by archmage (2009-01-24 22:23:26)


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#3 2009-01-24 22:17:30

mrweston
Scratcher
Registered: 2007-12-13
Posts: 100+

Re: List - to - variable

Except if the digits are in the order Jello gave, it'd be the reverse: [set i to (length of list)], and [change i by (-1)].

Offline

 

#4 2009-01-24 22:22:31

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: List - to - variable

mrweston wrote:

Except if the digits are in the order Jello gave, it'd be the reverse: [set i to (length of list)], and [change i by (-1)].

Oh yeah you are correct, I'll just fix my post.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#5 2009-01-25 13:17:56

Jello715
Scratcher
Registered: 2008-10-11
Posts: 95

Re: List - to - variable

Okay, thanks  smile

Offline

 

Board footer