Statalist


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

st: How do I write a directory listing to a file under Windows


From   Ulrich Kohler <[email protected]>
To   statalist <[email protected]>
Subject   st: How do I write a directory listing to a file under Windows
Date   Thu, 14 May 2009 11:25:17 +0200

Dear all,


I drafted two little programs -ldta- and -ldo- that provide a clickable
list of .dta files or .do files in the working directory.
Unfortunatelly, as they stand, the programs only work for Unix/Linux, as
I do not know how I can write a text-file with filenames into a file
under Windows (see program code below). I thought of

. log using x
. quietly dir *.dta
. log close

but obviously this doesn't help. I also thought of 

sh dir *.dta > 11

but I cannot test it as I don't have access do Windows-machine with
Stata right now.

Any hints most appreciated.

Uli

---------------------------------------------------ldo.ado
*! version 0.1 Mai 14, 2009 @ 11:05:32 UK
*! Clickable list of .do files
program ldo
version 10.0


// Create file with File-list
tempname dolog
sh ls *.do > `dolog'
tempname dolist 

// Open with file
file open `dolist' using `dolog', read text
local linenum = 0
file read `dolist' line

// Display filenames with clickable items
while r(eof)==0 {
  local linenum = `linenum' + 1
  display as text %5.0f `linenum' 	///
    as result `"{col 6} `macval(line)' "'		///
  `"{right:[{stata `"view "`macval(line)'""':view}]{space 5}[{stata
`"doedit "`macval(line)'""':edit}]{space 5}[{stata `"do
"`macval(line)'""':do}]{space 5}[{stata `"erase
"`macval(line)'""':{err}erase}]}"'  
  file read `dolist' line
}
file close `dolist'

end
exit

Author: Ulrich Kohler
	Tel +49 (0)30 25491 361
	Fax +49 (0)30 25491 360
	Email [email protected]

----------------------------------------------------------------------


-- 
[email protected]
030 25491-361

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index