Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: Creating automatic log file when I start Stata in MAC


From   Donald Spady <dspady@ualberta.ca>
To   Statalist Statalist <statalist@hsphsun2.harvard.edu>
Subject   st: Creating automatic log file when I start Stata in MAC
Date   Thu, 2 Dec 2010 14:44:13 -0700

I am trying to modify a program called set_log_file.ado to put into my profile.do so as to prompt me to enter a filename for a logfile.  I am doing this for Stata 11 in MAC OS (snow leopard) 
When I try what is written below, it does not prompt me for a file name and just goes on to the end and then says "file/documents/statlogs/.log could not be opened.
It is not my program, but I got it from somewhere many years ago and it worked OK on a PC.  Now I have a MAC and am having some teething problems.

The program is as follows

macro drop DB*
capture program drop set_log_file
program define set_log_file
  version 7.0

local x : display %dNDY date("$S_DATE","dmy") substr("$S_TIME",1,2) substr("$S_TIME",4,2)
global DB_filename "Enter log file name:"
*window control static DB_filename 10 10 100 10
*window control edit 10 20 175 8 DB_fname
*window control button "OK" 10 40 50 10 DB_ok default
*window control button "Cancel" 70 40 50 10 DB_can escape
global DB_ok "exit 3001"
global DB_can "exit 3000"

* change the 400 400 co-ordinates below to centre the dialog box on your own screen
* if you want smcl output, just drop the +."log" part below
* and change "basic.log" to "basic" (or any other name that suits)
* capture noisily window dialog "Log file details"  400 400 200 70
if _rc==3001 {
  global DB_fname="$DB_fname.log"
  }
  else
if _rc==3000 {
    global DB_fname="basic.log"
  }
*add your own path statements on the following line
global lfile="/documents/statalogs/"+"$DB_fname"
log using $lfile, append
*log using $DB_fname
end

The *window lines are commented out because the use of the word 'control' for some reason doesn't work

Where am I going wrong.

Many thanks

Don Spady

Nature bats last.


*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index