st: Update to godir.ado (cd to data directory)

Thanks to Dan Blanchette, a much improved little program to change
directory to one from which you've just -use-d a dataset. A suggestion
to StataCorp would be to add a -cd- option to -use-, so -use
"blah/thisdata, cd" would load the data and make blah the current
directory.
program godir
version 8
if strpos(reverse("$S_FN"),"/") {
local lastslash = length("$S_FN")-strpos(reverse("$S_FN"),"/")
}
else {
local lastslash = length("$S_FN")-strpos(reverse("$S_FN"),"\")
}
local target = substr("$S_FN", 1,`lastslash')
if strpos("`target'", ".dta") local target= "`c(pwd)'"
cd "`target'"
end
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/