Printf [message #91791] |
Thu, 27 August 2015 02:08  |
Dete van Eeden
Messages: 32 Registered: July 2015
|
Member |
|
|
This makes No sense to me. I have the following:
filename = 'maks'+strcompress(xx)+'.txt'
File1 = filepath(filename,subdirectory = ['Final'])
openw,lun,File1,/get_lun
then I get the error OPENW: Expression must be a scalar or 1 element array in this context: FILE1.
before even getting to the printf part.
thanks
|
|
|
Re: Printf [message #91792 is a reply to message #91791] |
Thu, 27 August 2015 02:26   |
Yngvar Larsen
Messages: 134 Registered: January 2010
|
Senior Member |
|
|
This probably means that your variable XX is an array (possibly with one element). Try
filename = 'maks'+strcompress(xx[0])+'.txt'
File1 = filepath(filename,subdirectory = ['Final'])
openw,lun,File1,/get_lun
As a side note:
IDL> print, filepath('somefile',subdirectory = ['Final'])
/usr/local/exelis/idl82/Final/somefile
Are you sure you really want to write to the default IDL root directory? If not, you can do something like this:
IDL> root_dir = '/my/data/directory/'
IDL> print, filepath('somefile',subdirectory = ['Final'], root_dir=root_dir)
/my/data/directory/Final/somefile
On Thursday, 27 August 2015 11:08:40 UTC+2, Dete van Eeden wrote:
> This makes No sense to me. I have the following:
>
>
> filename = 'maks'+strcompress(xx)+'.txt'
>
> File1 = filepath(filename,subdirectory = ['Final'])
>
> openw,lun,File1,/get_lun
>
> then I get the error OPENW: Expression must be a scalar or 1 element array in this context: FILE1.
>
> before even getting to the printf part.
>
> thanks
|
|
|
|
Re: Printf [message #91797 is a reply to message #91793] |
Fri, 28 August 2015 03:40   |
Nikola
Messages: 53 Registered: November 2009
|
Member |
|
|
On Thursday, August 27, 2015 at 12:26:22 PM UTC+1, Dete van Eeden wrote:
> Thank you! it worked.
>
> funny thing is i use xx through the whole program in exactly the same way without a problem, only get an error at the last one
>
> thanks for the side note!!
The problem that you had is in the OPENW line. If you define file1 as you did, then file1 is an array (what is ok), but with OPENW you cannot open more than one file. You could also make it as:
filename = 'maks'+strcompress(xx)+'.txt'
File1 = filepath(filename,subdirectory = ['Final'])
openw,lun,File1[0],/get_lun
...
|
|
|
Re: Printf [message #91799 is a reply to message #91791] |
Fri, 28 August 2015 15:21  |
joyrles1996
Messages: 27 Registered: August 2015
|
Junior Member |
|
|
Em quinta-feira, 27 de agosto de 2015 06:08:40 UTC-3, Dete van Eeden escreveu:
> This makes No sense to me. I have the following:
>
>
> filename = 'maks'+strcompress(xx)+'.txt'
>
> File1 = filepath(filename,subdirectory = ['Final'])
>
> openw,lun,File1,/get_lun
>
> then I get the error OPENW: Expression must be a scalar or 1 element array in this context: FILE1.
>
> before even getting to the printf part.
>
> thanks
;Create of file
get_lun, u
openw, u, 'C:\Users\Joyrles\Desktop\IDL\file.txt', get_lun
;edit the file
printf, u, datas
;close your file
close, u
;release the unit
free_lun, u
|
|
|