keep an if statement updating per frame in function Update

I'm trying to randomly change the speed of the rotation of an object in my scene. What I want is for the object to rotate at a speed of, lets say, 10 *Time.deltaTime and keep this speed for a set amount of time (again lets say 10(seconds)).

After the set amount of time has passed, I want the script to then calculate the next randomly selected speed for the rotation and to rotate the object at this speed for another randomly selected amount of time.

The script should then repeat randomly changing the speed of rotation and the time this speed lasts for the object.

This is what I have so far:

var myNumbers = 10;

function Update () 
{   
    var chance = Random.Range(0, 4);

    //transform.Rotate(randomNumbers[-20], 0, 0);

    if (chance == 1)
    {
        Debug.Log("RandomA is Go");
        amtToMove = myNumbers * Time.deltaTime;
        transform.Rotate(myNumbers*Time.deltaTime, 0, 0);
    }

    if (chance == 0)
    {
        Debug.Log("RandomB is go");
        transform.Rotate(-10*Time.deltaTime, 0, 0);
    }

    if (chance == 2)
    {
        Debug.Log("RandomC is Go");
        transform.Rotate(20*Time.deltaTime, 0, 0);
    }

    if (chance == 3)
    {
        Debug.Log("RandomD is Go");
        transform.Rotate(-20*Time.deltaTime, 0, 0);
    }    
}

I know we can't yield in a function update, but is there anyway to keep the transform.Rotate continuing for a set amount of time, without calculating the next chance variable?

I'm sure I should be using arrays, but I can't quite figure out how to use them with integers...

Thanks in advanced, any help would be grateful.

Greg

This issue has been resolved, if anyone has a similar issue or questions about the code feel free to drop me a mail!

Greg

Your script looks really strange... I don't even get what it should do.

According to your explanation i would do something like that:

var nextChange : float = 0.0;
var currentSpeed : float = 10.0;

function Update()
{
    if (Time.time > nextChange)
    {
        nextChange = Time.time + Random.Range(2.0,10.0); // wait 2 - 10 sec.
        currentSpeed = Random.Range(2.0,10.0);
    }
    transform.Rotate(currentSpeed * Time.deltaTime, 0, 0);
}