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

Home » Public Forums » archive » Re: Path/Directory String
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: Path/Directory String [message #55045] Tue, 31 July 2007 08:31
payon is currently offline  payon
Messages: 11
Registered: July 2007
Junior Member
On 31 Jul., 16:28, "Jeff N." <jnett...@utk.edu> wrote:
> On Jul 31, 8:28 am, pa...@gmx.de wrote:
>
>> with the whole path. Is there any possibility to get just the
>> filenames in a path, without any path link?
>
> Try this and see if it doesn't also do what you want:
>
> fnames = file_basename(files)
>
> Jeff

Yes, this also works fine, thanks!
Re: Path/Directory String [message #55046 is a reply to message #55045] Tue, 31 July 2007 07:28 Go to previous message
Jeff N. is currently offline  Jeff N.
Messages: 120
Registered: April 2005
Senior Member
On Jul 31, 8:28 am, pa...@gmx.de wrote:
> with the whole path. Is there any possibility to get just the
> filenames in a path, without any path link?
>

Try this and see if it doesn't also do what you want:

fnames = file_basename(files)


Jeff
Re: Path/Directory String [message #55049 is a reply to message #55046] Tue, 31 July 2007 06:10 Go to previous message
payon is currently offline  payon
Messages: 11
Registered: July 2007
Junior Member
>
> You might try moving to the directory you selected (not
> possible with the way you are writing the code, but it
> shouldn't be written that way anyhow, so...) and *then*
> using FILE_SEARCH to look for the files. You can use the
> CD command to change directories.
>
> theDir = DIALOG_PICKFILE(/DIRECTORY)
> IF theDir EQ "" THEN RETURN
> CD, theDir, CURRENT=currentDir
> theFiles = FILE_SEARCH('*.tif')
> CD, currentDir
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

Wow, thanks a lot again! Very simple, but very clever. I didn't think
about to change the directory. But this is the simpliest way to get
just the filename! So i wish you to have a nice day and thanks again,
david!

By the way, i've bought your book IDL Programming Techniques, 2nd
Edition. It is really fantastic! I learned a lot, and it's also a big
help with widget programming. I still use it as my reference IDL book,
because you describe things on a very simple and unterstandable way!
It would be also very great, if you could also describe the
call_external routine as well as make_dll to implement some simple C
code in IDL. Maybe in the 3rd edition? :) Because I didn't find any
book where it was explained clearly. Of course, IDL doesn't need any C
functions. It's more powerful, but I had to control my Camera via a
frame grabber. And this was only possible with C.. Ok.. thanks and
bye ..

Martin
Re: Path/Directory String [message #55050 is a reply to message #55049] Tue, 31 July 2007 05:47 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
payon@gmx.de writes:

> Ah all right thanks a lot, it works!
> And now i have the next small problem.

You may have more problems then you realize when
you put functions with CANCEL buttons inside of
other functions, but I guess you will discover that
soon enough. :-)

> Now i tried to read out all filenames which are included in the
> selected path
> with files=file_search(dialog_pickfile(/dir),'*.tif')
> I wanted to compare them with a defined string array, to know which
> files are missing, and so which computations cannot be proceed.
> the problem is, that in my defined array, i just have the filenames.
> Because the path is variable. But the result of
> files=file_search(dialog_pickfile(/dir),'*.tif') gives me the filename
> with the whole path. Is there any possibility to get just the
> filenames in a path, without any path link?

You might try moving to the directory you selected (not
possible with the way you are writing the code, but it
shouldn't be written that way anyhow, so...) and *then*
using FILE_SEARCH to look for the files. You can use the
CD command to change directories.

theDir = DIALOG_PICKFILE(/DIRECTORY)
IF theDir EQ "" THEN RETURN
CD, theDir, CURRENT=currentDir
theFiles = FILE_SEARCH('*.tif')
CD, currentDir

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Path/Directory String [message #55051 is a reply to message #55050] Tue, 31 July 2007 05:28 Go to previous message
payon is currently offline  payon
Messages: 11
Registered: July 2007
Junior Member
>
> Set the DIRECTORY keyword to DIALOG_PICKFILE and you can only
> select directories.
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")


Ah all right thanks a lot, it works!
And now i have the next small problem.

Now i tried to read out all filenames which are included in the
selected path
with files=file_search(dialog_pickfile(/dir),'*.tif')
I wanted to compare them with a defined string array, to know which
files are missing, and so which computations cannot be proceed.
the problem is, that in my defined array, i just have the filenames.
Because the path is variable. But the result of
files=file_search(dialog_pickfile(/dir),'*.tif') gives me the filename
with the whole path. Is there any possibility to get just the
filenames in a path, without any path link?

thanks a lot again!

martin
Re: Path/Directory String [message #55052 is a reply to message #55051] Tue, 31 July 2007 04:58 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
payon@gmx.de writes:

> Is there also any possibility to get such a string only when choosing
> a directory?
> My problem is, that i want the user to choose only a directory and not
> a specifiied file.. because in the directory itself, there are always
> the same filenames, which have to be analyzed. But what changes is
> file path. So I want the user to give a possibility to browse and to
> select the current project path in my widget.
> any suggestions?

Set the DIRECTORY keyword to DIALOG_PICKFILE and you can only
select directories.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: ROI Scaling
Next Topic: Re: control widgets

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

Current Time: Wed Oct 08 15:27:20 PDT 2025

Total time taken to generate the page: 0.00478 seconds