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

#1 2011-09-30 15:00:16

lbwiese
New Scratcher
Registered: 2011-09-30
Posts: 3

how do i intialize variables?

i am wondering how to assign numbers to the variables i have created after a calculation, so they can be read by the sprite.

Offline

 

#2 2011-09-30 15:02:06

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: how do i intialize variables?

Set [Variable] to (#)

Is that what you mean?

Offline

 

#3 2011-09-30 15:50:25

lbwiese
New Scratcher
Registered: 2011-09-30
Posts: 3

Re: how do i intialize variables?

i am trying to set a Maxvalue variable to the largest number from a list of numbers i have randomly chosen

Offline

 

#4 2011-09-30 16:00:50

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: how do i intialize variables?

I take it you use a list? I'll call the list "list"

This will need 2 variables, I and Max

Here's the script:

set [i] to (2)
Set [Max] to (Item (1) of [List])
Repeat ((Length of [List]) - (1) )
  If <(Max) < (Item (I) of [List]) >
    Set [Max] To (Item (I) of [List])
  {End of If}
  Change (I) by (1)
{End of Repeat}

I hope this is understandable  smile

Last edited by laptop97 (2011-09-30 16:01:02)

Offline

 

#5 2011-09-30 16:08:36

lbwiese
New Scratcher
Registered: 2011-09-30
Posts: 3

Re: how do i intialize variables?

Well i need to find the max and minimum values from the list.. and have the sprite say them. my only problem is that the numbers for the max and minimum aren't correct.

Offline

 

#6 2011-09-30 16:19:55

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: how do i intialize variables?

lbwiese wrote:

Well i need to find the max and minimum values from the list.. and have the sprite say them. my only problem is that the numbers for the max and minimum aren't correct.

The post above is to find the max. Try that first.

Offline

 

Board footer