Nick,
From: "Nick Cox" <[email protected]>
To: <[email protected]>
Subject: st: RE: Clickable examples in ado help files
Date sent: Thu, 18 Sep 2003 18:44:30 +0100
Send reply to: [email protected]
> Mark Schaffer
> >
> > A couple of questions for you:
> >
> > 1. What do you think of clickable examples in a command
> > help file?
> > That is, if the example in the help file is
> >
> > ivreg2 y1 x1 x2 (y2 y3 = z1 z2 z3), gmm ffirst
> >
> > and you click on this line, then the command is executed. It's
> > possible to do this in smcl with {stata <command> : <text of the
> > command> } , but is it worth it?
>
> Yes. Various graph help files are examples.
>
> > 2. This would work only if the dataset that the example uses is in
> > memory. I tried to put a clickable command to load the data in the
> > help file with the command
> >
> > {stata use "http://fmwww.bc.edu/ec-p/data/macro/abdata.dta"
> > : . stata
> > use http://fmwww.bc.edu/ec-p/data/macro/abdata.dta}
> >
> > where the part following the : separator is the clickable text to
> > display to the user, and the "" are used because the URL
> > contains a :.
> >
> > Unfortunately, what gets displayed is
> >
> > //fmwww.bc.edu/ec-p/data/macro/abdata.dta" : . use
> > http://fmwww.bc.edu/ec-p/data/macro/abdata.dta
> >
> > (all on one line)
> >
> > and when I click on it, Stata tries to execute the command
> >
> > use "http
> >
> > with the following result:
> >
> > . use "http
> > file http.dta not found
> > r(601);
> >
> > What's happening is that Stata is ignoring the "" and treats the
> > first : in the URL as the separator for the smcl command.
> >
> > I'm using Stata 7 (but hoping to update soon....). Does
> > this happen
> > in Stata 8 too? Any ideas on a Stata 7 (or 8) workaround?
>
> I haven't thought of how much more difficult to do
> this in Stata 7. In Stata 8 I would look at -gr_example.ado-,
> which is not even -undocumented-, but fairly transparent.
>
> In essence, I suspect that you _must_ do it indirectly.
> At a minimum you have to -preserve-, read in the example dataset, do
> whatever it is and -restore-. You can't do all that without bundling
> it in a program. -gr_example- is a template.
Question 1:
By this do you mean that in the smcl help file code, I need a line
like
{stata : loadhelpdata. stata use http://fmwww.bc.edu/ec-p/data/macro/abdata.dta}
where loadhelpdata is a separate .do file that loads the data?
Question 2:
Shouldn't the {stata} smcl command be as clever about :s as the {net}
smcl command? This would eliminate the need for messy little
auxiliary files in a command package.
Comment:
I don't think I would -preserve- the data etc., because I would want
the user to be able to click on various examples separately. Rather,
I would leave it to the user to voluntarily clear memory before
clicking on the line in the help display that loads the example
dataset. If Stata complains that it can't load the example data
because the existing data would be lost, that's fine by me.
Thanks, as always, for your input and help.
--mark
>
> Nick
> [email protected]
>
> *
> * For searches and help try:
> * http://www.stata.com/support/faqs/res/findit.html
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
Prof. Mark E. Schaffer
Director
Centre for Economic Reform and Transformation
Department of Economics
School of Management & Languages
Heriot-Watt University, Edinburgh EH14 4AS UK
44-131-451-3494 direct
44-131-451-3008 fax
44-131-451-3485 CERT administrator
http://www.som.hw.ac.uk/cert
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/