Perhaps you can this by indirection:
--------------------- mydo.do
log using `1'
di "`2'"
do `2'
---------------------
Thus
mydo mylog.txt example.do
is interpreted as
log using mylog.txt
di "example.do"
do example.do
Use " " to bind filenames with spaces.
[...]
This is similar in spirit to a little program I wrote recently. Mine opens
a log and invokes a do-file, both with the same base name (as is typical in
the way I work); it then closes the log, unless you use the -noclose-
option. It uses -syntax- and has some code to check for various
conditions. Here is is, in case anyone wants it. This is a bit different
from what Eddy asked for in that it assumes that the log and do-file will
have the same base name. But it could be altered to use possibly distinct
names. Also, it has -text- as the hard-coded log type; that could be made
into an option as well.