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 
Return to the default flat view Create a new topic Submit Reply
Re: returning filename suffix [message #40605] Mon, 23 August 2004 09:04 Go to previous 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/
[Message index]
 
Read Message
Read Message
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: Fri Oct 10 10:37:29 PDT 2025

Total time taken to generate the page: 1.99928 seconds