Opening variable files [message #7951] |
Thu, 30 January 1997 00:00  |
Christopher E. Crabtr
Messages: 1 Registered: January 1997
|
Junior Member |
|
|
I am an undergraduate as Washington University. We purchased IDL in the
summer of 96. I am currently trying to write a widget based application
and I ran into a problem. I want the user to be able to open a file of
his or her choosing, but when I try to use the statement
openr, 1, filename
where filename is a string (variable) I get a message saying that a scalar
value is expected. Is there any way to allow the user to enter in the new
file name without exiting the application and recompiling the program with
the new 'filename' inserted.
Thanks,
Chris Crabtree
cecrabtr@artsci.wustl.edu
|
|
|
|
Re: Opening variable files [message #8049 is a reply to message #7951] |
Thu, 30 January 1997 00:00   |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Chris Crabtree" <cecrabtr@artsci.wustl.edu> writes:
> I am currently trying to write a widget based application
> and I ran into a problem. I want the user to be able to open a file of
> his or her choosing, but when I try to use the statement
>
> openr, 1, filename
>
> where filename is a string (variable) I get a message saying that a scalar
> value is expected. Is there any way to allow the user to enter in the new
> file name without exiting the application and recompiling the program with
> the new 'filename' inserted.
Chris, you probably got this filename from a text widget. When you
get the value of a text widget, you always are returned a string
*array*, even if there is only one "thing" in your text widget.
You can make your program work by typing this:
openr, 1, filename(0)
But this is lousy code. :-)
I'd use this:
OPENR, lun, filename(0), /GET_LUN
This will save you some headaches down the road debugging
your programs. Tell your advisor you need a copy of "Building
Graphical User Interfaces in IDL", too. You can get it from RSI.
David
-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
2642 Bradbury Court, Fort Collins, CO 80521
Phone: 970-221-0438 Fax: 970-221-4762
E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
-----------------------------------------------------------
|
|
|
Re: Opening variable files [message #8075 is a reply to message #7951] |
Tue, 04 February 1997 00:00  |
D.Kennedy
Messages: 26 Registered: January 1997
|
Junior Member |
|
|
In article <Pine.SOL.3.95.970130104307.19425B-100000@ascc.artsci.wustl.edu>,
"Christopher E. Crabtree" <cecrabtr@artsci.wustl.edu> writes:
> I am an undergraduate as Washington University. We purchased IDL in the
> summer of 96. I am currently trying to write a widget based application
> and I ran into a problem. I want the user to be able to open a file of
> his or her choosing, but when I try to use the statement
>
> openr, 1, filename
>
> where filename is a string (variable) I get a message saying that a scalar
> value is expected. Is there any way to allow the user to enter in the new
> file name without exiting the application and recompiling the program with
> the new 'filename' inserted.
I use this:
; Pop up a window and let the user select the datafile
SET_PLOT, 'X'
datafile= PICKFILE(GET_PATH=path, PATH='/home7/dcjk/M15-radio/', $
/READ, FILTER='*.data')
; Tidy up the pathname etc
IF STRMID(path(0), STRLEN(path(0))-1,1) NE '/' THEN path = path(0) + '/'
; Open file
OPENR, input, datafile, /GET_LUN
--
David Kennedy, Dept. of Pure & Applied Physics, Queen's University of Belfast
Email: D.Kennedy@Queens-Belfast.ac.uk | URL: http://star.pst.qub.ac.uk/~dcjk/
Hi! I'm a .signature virus! Copy me into yours and join the fun!
|
|
|