Ответ:1. I did not go out last night because I had been working all day.
2. When the musician became the director of the opera house, he had been living in this town for ten years.
3. When I noticed my mistake, I have been driving for an hour in the wrong direction
4. He had been taking the dog for a walk for two hours yesterday