How Can I Use Time in a For Loop?

I know it sounds like a dumb question, but it’s been bothering me for some time now.

I know how to use a for loop, but I don’t know how to use it with Unity’s time scale. My problem is this:

I need to do a block of code for randMovementTime which is a float variable created and assigned a Random.Range value in the Awake function. So the for loop would look like this:

for (i = 0; i > randMovementTime; statement3)
{
  // Block of code goes here...
}

I don’t know how to increment i in statement 3 at the rate of Unity’s time scale to make it equal randMovementTime.

To put it simply: I want to know how to do a for loop for a certain amount of time.

i would have to be time, but any version of time would be the time since level load or time since startup, but I need the time since the for loop was last triggered, so i needs to start at 0 and be incremented at the rate of the time since the for loop was last triggered.

Any help is greatly appreciated!

EDIT: I am using this for loop in the Update function, so no coroutines.

- Chris

I have tried to workaround this problem, but by doing so I have come across a smaller problem.

My workaround was to call a function from within the update function. My code went as follows:

function Update ()
{
  if (canMove == true && playerIsDead == false)
  {
    Movement ();
  }
}

function Movement ()
{
  while (moveDown == true)
  {
    transform.Translate (0, -Time.fixedDeltaTime * randSpeed, 0);

    yield WaitForSeconds (randMovementTime);
    moveDown = false;
    moveUp = true;

    break;
  }

  while (moveUp == true)
  {
    transform.Translate (0, Time.fixedDeltaTime * randSpeed, 0);

    yield WaitForSeconds (randMovementTime);
    moveUp = false;
    moveDown = true;

    break;
  }
}

The problem I had with the above code was that at normal speed, the object would move up more than it would move down. But it works fine when I do it frame-by-frame.