What am i doing wrong?

hi guys
im using sub moving_wait instead of delay, and controling speed. when im running the script it runs all the way and then “shutting down”, giving the familiar “stack overflow/underflow” error.
i guess i should end the loop with a quit, but cant find the right place for it in the script.
this is the script:

# zahal no 2nd
begin
  5807 7094 4276 8411 5668 4972 frame_0..5 20 0 20 1 20 2 20 3 20 4 20 5 speed speed speed speed speed speed # left1
  7268 6642 4902 frame_1_2_4 20 0 20 1 20 2 20 3 20 4 20 5 speed speed speed speed speed speed # left2
  9600 3267 4589 frame_1_2_4 20 0 20 1 20 2 20 3 20 4 20 5 speed speed speed speed speed speed # left3
  6398 4902 frame_2_4 20 0 20 1 20 2 20 3 20 4 20 5 speed speed speed speed speed speed # left4
  6016 7999 6016 6016 6016 6016 frame_0..5 20 0 20 1 20 2 20 3 20 4 20 5 speed speed speed speed speed speed # left5
  5807 9600 6398 8411 4902 4972 frame_0..5 20 0 20 1 20 2 20 3 20 4 20 5 speed speed speed speed speed speed # left6
  7268 6642 frame_1_2 8 0 8 1 8 2 8 3 8 4 8 5 speed speed speed speed speed speed # left7
  5320 6433 2432 5668 5563 frame_0..2_4_5 8 0 8 1 8 2 8 3 8 4 8 5 speed speed speed speed speed speed # Frame 0
  6990 frame_5 8 0 8 1 8 2 8 3 8 4 8 5 speed speed speed speed speed speed # Frame 1
  3267 frame_5 8 0 8 1 8 2 8 3 8 4 8 5 speed speed speed speed speed speed # Frame 2
  6642 frame_0 8 0 8 1 8 2 8 3 8 4 8 5 speed speed speed speed speed speed # Frame 3
  4728 4972 frame_0_5 30 0 30 1 30 2 30 3 30 4 30 5 speed speed speed speed speed speed # Frame 4
  5807 7094 4276 frame_0..2 30 0 30 1 30 2 30 3 30 4 30 5 speed speed speed speed speed speed # left1
  7268 6642 4902 frame_1_2_4 30 0 30 1 30 2 30 3 30 4 30 5 speed speed speed speed speed speed # left2
  9600 3267 4589 frame_1_2_4 30 0 30 1 30 2 30 3 30 4 30 5 speed speed speed speed speed speed # left3
  6398 4902 frame_2_4 30 0 30 1 30 2 30 3 30 4 30 5 speed speed speed speed speed speed # left4
  6016 7999 6016 6016 6016 6016 frame_0..5 30 0 30 1 30 2 30 3 30 4 30 5 speed speed speed speed speed speed # left5
  5807 9600 6398 8411 4902 4972 frame_0..5 30 0 30 1 30 2 30 3 30 4 30 5 speed speed speed speed speed speed # left6
  4276 5668 frame_1_2_4 30 0 30 1 30 2 30 3 30 4 30 5 speed speed speed speed speed speed # end
  7094 frame_1 30 0 30 1 30 2 30 3 30 4 30 5 speed speed speed speed speed speed # left1
  7268 6642 4902 frame_1_2_4 30 0 30 1 30 2 30 3 30 4 30 5 speed speed speed speed speed speed # left2
  9600 3267 4589 frame_1_2_4 30 0 30 1 30 2 30 3 30 4 30 5 speed speed speed speed speed speed # left3
  6398 4902 frame_2_4 30 0 30 1 30 2 30 3 30 4 30 5 speed speed speed speed speed speed # left4
  6016 7999 6016 6016 6016 6016 frame_0..5 30 0 30 1 30 2 30 3 30 4 30 5 speed speed speed speed speed speed # left5
  5807 9600 6398 8411 4902 4972 frame_0..5 30 0 30 1 30 2 30 3 30 4 30 5 speed speed speed speed speed speed # left6
  7268 6642 frame_1_2 20 0 20 1 20 2 20 3 20 4 20 5 speed speed speed speed speed speed # left7 (speed for left 1)
repeat

sub frame_0..5
  5 servo
  4 servo
  3 servo
  2 servo
  1 servo
  0 servo
  moving_wait
  return

sub frame_1_2_4
  4 servo
  2 servo
  1 servo
  moving_wait
  return

sub frame_2_4
  4 servo
  2 servo
  moving_wait
  return

sub frame_1_2
  2 servo
  1 servo
  moving_wait
  return

sub frame_0..2_4_5
  5 servo
  4 servo
  2 servo
  1 servo
  0 servo
  moving_wait
  return

sub frame_5
  5 servo
  moving_wait
  return

sub frame_0
  0 servo
  moving_wait
  return

sub frame_0_5
  5 servo
  0 servo
  moving_wait
  return

sub frame_0..2
  2 servo
  1 servo
  0 servo
  moving_wait
  return

sub frame_1
  1 servo
  moving_wait
  return

sub moving_wait
begin
get_moving_state
while
repeat
return

thanks!

Hello, am_sy.

You are only adding two values to the stack on the line above, but the frame_1_2_4 subroutine expects 3 values. This causes a stack underflow. I found this by removing chunks of code from your loop, and then testing it to see if the error still occurred.

–David

thanks for the answer, you are allways so great guys.
i will try to find out how this value disapear…
A