If you want to wait for finishing of a function you should do this way:
Code:
function first_func()
{
        var my_value = 0;	
        while(1)
	{
		my_value = sec_func(50); //no correct result
		wait_for(sec_func);
		wait(1);
	}
}


In hope i understood you.