How do you dig in Ruby?

you find the TM dig and use it on a Pokemon then while its in your party goto a cave/dungeon and use dig to return to the begining.