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]

Re: st: Browse to obtain directory name


From   Robert Picard <[email protected]>
To   [email protected]
Subject   Re: st: Browse to obtain directory name
Date   Fri, 19 Jul 2013 11:07:53 -0400

I assume that you are referring to the -window fopen- Stata command
that lets you use the standard operating system dialog to browse for
and select a file. There's a way to mimic the behavior of -window
fopen- for directories in Stata 12 and above. This requires short side
trip via the esoteric universe of dialog programming in Stata. Save
the following "dopen.ado" and "dopen.dlg" files somewhere along the
-adopath- where Stata can find them. Then just type "dopen" in the
command window (no quotes) to invoque the command. That will display
the Stata dialog below that let's you browse for a directory. Type
-return list- to see the results.

Robert

*--------- dopen.ado
---------------------------------------------------------------
*! version 1.0.0  19jul2013  Robert Picard, [email protected]
program define dopen, rclass

	version 12
	
	syntax [anything], [dopen]
	
	if "`dopen'" == "" db dopen
	else {
		dis `"`anything'"'
		return local dpath `anything'
	}
		
end
*--------- dopen.ado
---------------------------------------------------------------

*--------- dopen.dlg
---------------------------------------------------------------
/*
*! dopen VERSION 1.0.0  19jul2013  Robert Picard, [email protected]
*/

VERSION 12.0
MODAL
INCLUDE _std_small
POSITION . . _dlgwd 200
OK ok1, label("OK")
CANCEL can1, label("Cancel")

HELP hlp1, view("help cd")
RESET res1

DIALOG main, label("dopen - Select a directory")		///
	tabtitle("Main")
	
BEGIN
  	GROUPBOX	gb_using  _lft  _top  _iwd  _ht8, ///
		label("Please select a directory")
		
	TEXT	tx_using	_ilft	_ls	_inwd	.,	///
		label("directory name:")
	
		
	BROWSE br_open @		_ss	@		., ///
		error("Directory to use") label("Browse...") directory
END

PROGRAM command
BEGIN
	require main.br_open
	put `"dopen ""'
	put main.br_open
	put `"""'
	put ", dopen"
	stata hidden
END
*--------- dopen.dlg
---------------------------------------------------------------


On Thu, Jul 18, 2013 at 4:25 PM, Harris, Linda J <[email protected]> wrote:
> Is there a command similar to fOpen that allows you to browse to a directory and capture its path?
>
> Thank you,
> Linda
*
*   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