Statalist


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

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


From   Roy Wada <[email protected]>
To   <[email protected]>
Subject   RE: st: How do I write a directory listing to a file under Windows
Date   Thu, 14 May 2009 03:35:04 -0700

 
Look at -cdout-, available from SSC, which will produce a clickable for
the cd folder.
 
Also at -capfile-, which will do it for .txt or .smcl log files.
 
Directly opening .do or .dta will trigger a new session of Stata, which was
not useful to me.

You might extract file names directly from macro. This is platform-independent.

prog define click
*! Clickable stuff
args suffix
local name: dir `"`c(pwd)'"' files "*.`suffix'"
tokenize `"`name'"'
local num 1
while `"``num''"'~="" {
   local var `"``num''"'
   local cl_text `"{browse `"``num''"'}"'
   noi di as txt `"`cl_text'"'
   local num=`num'+1
}
end
 
click txt
click do

Roy
 
> 
> 
> 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]
> 
_________________________________________________________________
Hotmail® has a new way to see what's up with your friends.
http://windowslive.com/Tutorial/Hotmail/WhatsNew?ocid=TXT_TAGLM_WL_HM_Tutorial_WhatsNew1_052009
*
*   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