comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: returning filename suffix
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: returning filename suffix [message #40605] Mon, 23 August 2004 09:04 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Tobi writes:

> is there an existing idl routine that returns a filename suffix?
>
> i have chosen a number of files using the DIALOG_PICKFILE() routine
> and now want to do different things depending on the suffix (IMG, JPG,
> GFX ...) of the file chosen.

There is a FILE_DIRNAME function for getting the directory
part of a file path. And a FILE_BASENAME function for getting
the base filename part of a file path. But, oddly I think,
neither gives you the opportunity to get the file extension.
(Although it is certainly not hard to extract the extension
from a base filename.)

So I've written my own function, FSC_BASE_FILENAME, that
can give you the base filename, the directory, and
the file extension, all at once. For example:

IDL> path = 'C:\RSI\David\Catalyst\catcoord__define.pro'
IDL> basename = FSC_BASE_FILENAME(path, Directory=dir, Extension=ext)
IDL> Print, dir
C:\RSI\David\Catalyst\
IDL> Print, basename
catcoord__define
IDL> Print, ext
pro

You can find the program here:

http://www.dfanning.com/programs/fsc_base_filename.pro

I only use this program in interactive programs, so the input
is expected to come from something like Dialog_Pickfile
or Filepath. I haven't tested it on anything else. :-)

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: returning filename suffix [message #40687 is a reply to message #40605] Tue, 24 August 2004 07:25 Go to previous message
tbeetz is currently offline  tbeetz
Messages: 9
Registered: May 2003
Junior Member
david - thanks for the program! i also found it strange that there is
no routine provided by idl, since they could just return the extension
when they get they strip the filename ... thanks again!

TOBI
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: plot & oplot
Next Topic: Bug with object graphics, app_scroll and the mouse in 6.1 under Windows.

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:49:56 PDT 2025

Total time taken to generate the page: 0.00483 seconds