Re: file_expand_path [message #51898 is a reply to message #35617] |
Tue, 12 December 2006 16:11  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
damonanomad@gmail.com writes:
> I am trying to to use IDL and have run into some a strange behavior
> in 6.2 using file_expand_path. The following lines illustrate what I
> am seeing:
>
> IDL> file_a=file_expand_path('full28field.table')
> IDL> print, file_a
> C:\DocSet\MyDoc\IDL\working\full28field.table
> IDL> print, file_test(file_a)
> 0
> IDL> file_b='C:\DocSet\MyDoc\IDL\working\FieldInfo\full28field.ta ble'
> IDL> print, file_test(file_b)
> 1
>
> As can be seen above, the path that it is returning is not the true
> path of the file but I don't know why it isn't.
Probably because that function doesn't try to determine
the "true path" of the file. It just "builds" a path
from wherever you happen to be located at the moment
you execute the function. That is, if your current
working directory is C:\somewhere, then when you
execute the function you get this:
IDL> Print, File_Expand_Path('foo.pro')
C:\somewhere\foo.pro
This is true whether foo.pro exists or not! (This
is basically the way FILEPATH works, but perhaps the
name of this function doesn't disappoint you with inflated
expectations.)
> The search path that I
> have set in "Preferences" (in addition to default) is
> 'C:\DocSet\MyDoc\IDL' and its sub-directories. (note that
> '\DocSet\MyDoc' = '\Documents and Settings\user\My Documents' in
> reality)
> Any ideas out there why I am running into this problem? Suggestions
> would be greatly appreciated.
You will have to get into the directory where the file exists
before you execute the command:
IDL> CD, 'fieldinfo'
IDL> Print, File_Expand_Path('full28field.table')
C:\DocSet\MyDoc\IDL\working\FieldInfo\full28field.table
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.")
|
|
|