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: Dialog box for opening a file


From   Alan Riley <[email protected]>
To   [email protected]
Subject   Re: st: Dialog box for opening a file
Date   Wed, 27 Mar 2013 14:30:00 -0500

David Epstein ([email protected]) is trying to use Stata's
programmable dialog system to create his own simple dialog box
to open a .csv file, but his dialog box isn't working:

> This is a simple operation, but after hours of frustration I can't
> figure out how to program a simple dialog box to open a .csv file. The
> command I want to emulate is:
> 
> insheet using "myfile.csv", names clear
> 
> My dialog box program looks like this now, but I can't get Stata to
> open the file:
> ...

I'll leave David's dialog box code under my signature below.

> I'm guessing the problem is with my treatment of the quotation marks,
> but none of the approximately one gazillion variations I've tried
> works. Or perhaps it's something else basic that I've overlooked. Any
> help would be appreciated.

It looks like the "TEXT" line in the dialog box code is split
into two lines in the middle of the label().  If I copy David's
code and join these two lines to be one line

     TEXT     tx_dly      10  40   320  .,  label("Select file with data
   to be processed:")

then the dialog works as expected for me.

As an aside, if all David wants to do is present a simple file dialog to
prompt the user to choose an input file, and he doesn't want to put any
other options on the dialog box, then he may wish to look at
-help window fopen- and the example at the bottom of that help file.


Alan
[email protected]



> 
> /*
>   daily_file.dlg
> */
> 
> 
> VERSION 12
> 
> POSITION . . 410 250
> 
> DIALOG main, label("Daily Data Processing") tabtitle("Main")
> BEGIN
>   TEXT     tx_dly      10  40   320  .,	label("Select file with data
> to be processed:")
>   FILE     fi_dly      10  +30  350  .,	error("Open file") label(Browse...) ///
>   			filter("CSV Files|*.csv|All Files|*.*")
> END
> 
> OK ok1,      label("OK")
> CANCEL can1, label("Cancel")
> SUBMIT sub1, label("Submit")
> HELP hlp1,   view("help generate")
> RESET res1
> COPY copy1
> 
> PROGRAM command
> BEGIN
>     put "insheet using "
>     put `"""'
>     require main.fi_dly
>     put main.fi_dly
>     put `"""'
>     put ", names clear "
> END
> 
*
*   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