Re: end-of-line termination [message #59178] |
Fri, 07 March 2008 12:33  |
Haje Korth
Messages: 651 Registered: May 1997
|
Senior Member |
|
|
Ben,
YES, this worked perfectly!
Thanks,
Haje
"ben.bighair" <ben.bighair@gmail.com> wrote in message
news:2250a3dc-d38f-40e7-99be-a2fdf71e01c2@e31g2000hse.google groups.com...
> On Mar 7, 12:36 pm, "Haje Korth" <haje.ko...@nospam.jhuapl.edu> wrote:
>> The only problem I find is that IDL and C format codes do not readily
>> mix.
>> Can "\r\n" be translated to an IDL format code? H.
>>
>
> I hope this isn't a red herring, but how about...
>
> openw,u,"file.txt",/get_lun & printf, u, "Doughnut", format
> ='($,A0,%"\r\n")'& free_lun ,u
>
> Ben
>
|
|
|
Re: end-of-line termination [message #59179 is a reply to message #59178] |
Fri, 07 March 2008 12:34  |
Haje Korth
Messages: 651 Registered: May 1997
|
Senior Member |
|
|
Thanks, Bob,
I see this working, too. I did end up with Ben's method, since it required
fewer changes.
Haje
"R.G. Stockwell" <nothanks@noemail.com> wrote in message
news:fqs44i$dlt$1@aioe.org...
> "Haje Korth" <haje.korth@nospam.jhuapl.edu> wrote in message
> news:fqrqom$386$1@aplnetnews.jhuapl.edu...
>> Hi,
>> I am writing ASCII files in IDL using PRINTF that require to have a CR+LF
>> end-of-line termination. Is there a way to force this in UNIX, which uses
>> LF only?
>>
>> Thanks,
>> Haje
>
> Hi Haje,
> I ran into this a while ago, I used IDL (on windows) to create
> scripts to execute fortan code on linux. If I remember correctly,
> I used a writeu,lun statement instead of printf,lun
>
> which did not append the end of line.
> You could concatenate the appropriate end of line to your
> string buffer, then writeu it to file
>
>
> Cheers,
> bob
>
>
|
|
|
Re: end-of-line termination [message #59182 is a reply to message #59178] |
Fri, 07 March 2008 11:13  |
R.G. Stockwell
Messages: 363 Registered: July 1999
|
Senior Member |
|
|
"Haje Korth" <haje.korth@nospam.jhuapl.edu> wrote in message
news:fqrqom$386$1@aplnetnews.jhuapl.edu...
> Hi,
> I am writing ASCII files in IDL using PRINTF that require to have a CR+LF
> end-of-line termination. Is there a way to force this in UNIX, which uses
> LF only?
>
> Thanks,
> Haje
Hi Haje,
I ran into this a while ago, I used IDL (on windows) to create
scripts to execute fortan code on linux. If I remember correctly,
I used a writeu,lun statement instead of printf,lun
which did not append the end of line.
You could concatenate the appropriate end of line to your
string buffer, then writeu it to file
Cheers,
bob
|
|
|
Re: end-of-line termination [message #59183 is a reply to message #59182] |
Fri, 07 March 2008 10:38  |
ben.bighair
Messages: 221 Registered: April 2007
|
Senior Member |
|
|
On Mar 7, 12:36 pm, "Haje Korth" <haje.ko...@nospam.jhuapl.edu> wrote:
> The only problem I find is that IDL and C format codes do not readily mix.
> Can "\r\n" be translated to an IDL format code? H.
>
I hope this isn't a red herring, but how about...
openw,u,"file.txt",/get_lun & printf, u, "Doughnut", format
='($,A0,%"\r\n")'& free_lun ,u
Ben
|
|
|
Re: end-of-line termination [message #59184 is a reply to message #59183] |
Fri, 07 March 2008 10:24  |
ben.bighair
Messages: 221 Registered: April 2007
|
Senior Member |
|
|
On Mar 7, 12:36 pm, "Haje Korth" <haje.ko...@nospam.jhuapl.edu> wrote:
> The only problem I find is that IDL and C format codes do not readily mix.
> Can "\r\n" be translated to an IDL format code? H.
>
I hope this isn't a red herring, but how about...
openw,u,"file.txt",/get_lun & printf, u, "Doughnut", format
='($,A0,%"\r\n")'& free_lun ,u
Ben
|
|
|
Re: end-of-line termination [message #59185 is a reply to message #59184] |
Fri, 07 March 2008 09:36  |
Haje Korth
Messages: 651 Registered: May 1997
|
Senior Member |
|
|
The only problem I find is that IDL and C format codes do not readily mix.
Can "\r\n" be translated to an IDL format code? H.
"ben.bighair" <ben.bighair@gmail.com> wrote in message
news:feeb16e9-11e1-4625-bb8a-b38fd6778991@34g2000hsz.googleg roups.com...
> On Mar 7, 11:48 am, Peter Clinch <p.j.cli...@dundee.ac.uk> wrote:
>> Haje Korth wrote:
>>> Hi,
>>> I am writing ASCII files in IDL using PRINTF that require to have a
>>> CR+LF
>>> end-of-line termination. Is there a way to force this in UNIX, which
>>> uses LF
>>> only?
>>
>> You could thug it with a system call from your program to unix2dos (or
>> whatever utility) after you've finished...
>
> Hi,
>
> That might be the easiest, but if you have a lot of these to do I
> think the C printf kind of formatting allows you to add combinations
> of "\f\n" to a line of output.
>
> ?printf-style
>
> gets you there.
>
> Cheers,
> Ben
>
|
|
|
Re: end-of-line termination [message #59188 is a reply to message #59185] |
Fri, 07 March 2008 08:59  |
Haje Korth
Messages: 651 Registered: May 1997
|
Senior Member |
|
|
Peter,
Thanks for your response. Is this really my only option? I know that I can
also "convert" the file by reading and writing the file in IDL character by
character and replacing the line endings. The problem is that this adds
significant overhead when lots of files 100MB each are written. Therefore I
wanted to write the files correct the first time around. I was wondering if
adding \r\n to the format statement would do the trick?
Haje
"Peter Clinch" <p.j.clinch@dundee.ac.uk> wrote in message
news:63da37F277atiU1@mid.individual.net...
> Haje Korth wrote:
>> Hi,
>> I am writing ASCII files in IDL using PRINTF that require to have a CR+LF
>> end-of-line termination. Is there a way to force this in UNIX, which uses
>> LF
>> only?
>
> You could thug it with a system call from your program to unix2dos (or
> whatever utility) after you've finished...
>
> Pete.
> --
> Peter Clinch Medical Physics IT Officer
> Tel 44 1382 660111 ext. 33637 Univ. of Dundee, Ninewells Hospital
> Fax 44 1382 640177 Dundee DD1 9SY Scotland UK
> net p.j.clinch@dundee.ac.uk http://www.dundee.ac.uk/~pjclinch/
|
|
|
Re: end-of-line termination [message #59189 is a reply to message #59188] |
Fri, 07 March 2008 08:59  |
ben.bighair
Messages: 221 Registered: April 2007
|
Senior Member |
|
|
On Mar 7, 11:48 am, Peter Clinch <p.j.cli...@dundee.ac.uk> wrote:
> Haje Korth wrote:
>> Hi,
>> I am writing ASCII files in IDL using PRINTF that require to have a CR+LF
>> end-of-line termination. Is there a way to force this in UNIX, which uses LF
>> only?
>
> You could thug it with a system call from your program to unix2dos (or
> whatever utility) after you've finished...
Hi,
That might be the easiest, but if you have a lot of these to do I
think the C printf kind of formatting allows you to add combinations
of "\f\n" to a line of output.
?printf-style
gets you there.
Cheers,
Ben
|
|
|
Re: end-of-line termination [message #59190 is a reply to message #59188] |
Fri, 07 March 2008 08:48  |
Peter Clinch
Messages: 98 Registered: April 1996
|
Member |
|
|
Haje Korth wrote:
> Hi,
> I am writing ASCII files in IDL using PRINTF that require to have a CR+LF
> end-of-line termination. Is there a way to force this in UNIX, which uses LF
> only?
You could thug it with a system call from your program to unix2dos (or
whatever utility) after you've finished...
Pete.
--
Peter Clinch Medical Physics IT Officer
Tel 44 1382 660111 ext. 33637 Univ. of Dundee, Ninewells Hospital
Fax 44 1382 640177 Dundee DD1 9SY Scotland UK
net p.j.clinch@dundee.ac.uk http://www.dundee.ac.uk/~pjclinch/
|
|
|