It looks to me like your using the Hi-Technic motor controller, right? I've no experience with this, but I think that the same rules that apply to MindStorms motors apply to these.
Try this code:
And this:
You see, the problem with your original code is that the nMotorRunState[] doesn't use a number as a condition. If you want to use a number, then just read the encoder value like in my second sample. If you use nMotorRunState[], then wait for it to be equal to runStateIdle.
Do either of these work?
_________________A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.