Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Integer program arguments not interpreted as integers (macro expansion question)


From   Ryan Turner <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Integer program arguments not interpreted as integers (macro expansion question)
Date   Fri, 13 Sep 2013 11:47:26 -0400

Dear Statalist:

I avoid asking beginner questions on the list because I don't want to waste people's time (and I, ahem, don't consider myself a beginner); but can somebody explain this macro insanity below?  I know _what_ I did (used an equal sign to force an arithmetic reassignment to the first program argument), but I do not understand _why_ it is necessary (why a macro, not being in double quotes, is not interpreted as an integer when clearly an integer is the only thing that makes sense here).

The purpose of this program is to quietly get timer parameters into the return variables (e.g., for -display r(t1) r(nt1)-).  Admittedly it only saves one line of code (I don't need to call -timer list- after -timer on #-) but it is (severally) in the middle of a large program.

Best,
Ryan


capture program drop timer_start
program timer_start
    quietly {
        local 1 = `1' // macro insanity
        timer on `1'
        timer list
    }
end

capture program drop timer_stop
program timer_stop
    quietly {
        local 1 = `1' // macro insanity
        timer off `1'
        timer list
    }
end

// Call it with:
timer clear
timer_start(99)
return list

sleep 2000
timer_stop(99)
return list


--
Ryan J. Turner <[email protected]>
Engineering and Public Policy
Carnegie Mellon University
+1-412-304-5014 (C) | +1-484-483-3244 (GV)


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index