[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: addendum: parse last command from ado file?

From   <>
To   <>
Subject   st: addendum: parse last command from ado file?
Date   Wed, 11 Nov 2009 12:52:37 +0100

Hi Statalisters,

the question was: 
While working in the command window: How can I access the last command
from within an ado in order to alter it in a specified way (without
having to retype anything) and run it again.

My example was to interchange row and column vars in a bivariate tab

There is one very simple (halfway) approach to this (still requires some
manual input)

program define tt
di "choose command"
di _request(tabcmd)

- Start ado (e.g. set function key F4 to tt;)
- choose recent command from review window or use "page up"-key from the
command line
- (Enter)
- Now the global $tabcmd is altered and executed.

User input is for example: F4 ->  2* PgUp -> Return (quite comfortable)


Second, a one-click-solution that works for me (Stata 10.1 on Win XP)
but I'm not shure if it will work in all settings.
In my setting the "#review"-command can be executed from the internal
do-editor but not from my external editor. So I created an one-liner
do-file "" containing "#review 2 1"
I also set function key F4 to tt1;

The basic idea is:

Start ado (over function key)
The ado file: 
- opens a log
- executes #review with "do"
- closes the log
- opens log via "file open"
- reads lines (using "file read ... line" in a "while"-loop until a line
starts with "2 " (the #review number)
- copies last line to local
And then:

User input is: F4 (very comfortable)


*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index