Naming the file as open through dialogue_pickfile [message #92746] |
Mon, 22 February 2016 21:33  |
mj999fine
Messages: 4 Registered: February 2016
|
Junior Member |
|
|
I am trying to read a file through the command
path='C:\LWP\'
file=dialog_pickfile(PATH =path,filter ='*TXT')
which has data to read and it is stored in some array.
The file names in the "PATH" folder has a sequence "A1.txt", "A2.txt", .... and 15 others.
Now I want to store the data in some another file.
I want to store data in a new sequence such as "MA1.txt", which suggests the file has been read.
so i want to add "M" in the newly saved file name along with old file name.
EX:
"M"+ "(original file name)".TXT
Is it possible in IDL 8.4 Win PC ?
|
|
|
Re: Naming the file as open through dialogue_pickfile [message #92748 is a reply to message #92746] |
Tue, 23 February 2016 06:27   |
Burch
Messages: 28 Registered: December 2013
|
Junior Member |
|
|
On Monday, February 22, 2016 at 11:33:35 PM UTC-6, mj99...@gmail.com wrote:
> I am trying to read a file through the command
>
> path='C:\LWP\'
> file=dialog_pickfile(PATH =path,filter ='*TXT')
>
> which has data to read and it is stored in some array.
> The file names in the "PATH" folder has a sequence "A1.txt", "A2.txt", .... and 15 others.
>
> Now I want to store the data in some another file.
> I want to store data in a new sequence such as "MA1.txt", which suggests the file has been read.
> so i want to add "M" in the newly saved file name along with old file name.
>
> EX:
> "M"+ "(original file name)".TXT
>
> Is it possible in IDL 8.4 Win PC ?
Since the output of dialog_pickfile() is a string you can use strmid() to remove the path. For example,
IDL> print, file
C:\LWP\A1.txt
IDL> print, strmid(file, 7)
A1.txt
IDL> print, 'M' + strmid(file, 7)
MA1.txt
Further info on strmid() and other useful routines:
http://www.exelisvis.com/docs/STRMID.html
http://www.exelisvis.com/docs/routines-87.html
-Jeff
|
|
|
Re: Naming the file as open through dialogue_pickfile [message #92749 is a reply to message #92748] |
Tue, 23 February 2016 07:23  |
Mats Löfdahl
Messages: 263 Registered: January 2012
|
Senior Member |
|
|
Den tisdag 23 februari 2016 kl. 15:27:56 UTC+1 skrev Jeff B:
> On Monday, February 22, 2016 at 11:33:35 PM UTC-6, mj99...@gmail.com wrote:
>> I am trying to read a file through the command
>>
>> path='C:\LWP\'
>> file=dialog_pickfile(PATH =path,filter ='*TXT')
>>
>> which has data to read and it is stored in some array.
>> The file names in the "PATH" folder has a sequence "A1.txt", "A2.txt", .... and 15 others.
>>
>> Now I want to store the data in some another file.
>> I want to store data in a new sequence such as "MA1.txt", which suggests the file has been read.
>> so i want to add "M" in the newly saved file name along with old file name.
>>
>> EX:
>> "M"+ "(original file name)".TXT
>>
>> Is it possible in IDL 8.4 Win PC ?
>
> Since the output of dialog_pickfile() is a string you can use strmid() to remove the path. For example,
Or file_basename().
|
|
|