Re: write unix textfile with windows idl [message #37722] |
Thu, 22 January 2004 10:16 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
> IDL is getting like Microsoft, doing all the thinking
> for you. How did it know I wanted to abbreviate "Interactive
> Data Language" to IDL!? Amazing. :-)
What's really amazing is how much faster my mouth works
than my brain. :-(
On re-reading the tip, I find I am really, REALLY
impressed with C style formatting. I've got to start
brushing up on that language....
Cheers,
David
P.S. Let's just say REGEX is on my list.
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: write unix textfile with windows idl [message #37723 is a reply to message #37722] |
Thu, 22 January 2004 10:08  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Michael Wallace writes:
> Here's a techtip explaining the basics of how to use C printf-style
> escape sequences: http://www.rsinc.com/services/techtip.asp?ttid=3616
The tip reads:
IDL> PRINT,'I','like','Interactive','Data','Language', $
FORMAT='(%"%s %s\t%1s",a1,a1)'
Which results in the following output:
I like IDL
IDL is getting like Microsoft, doing all the thinking
for you. How did it know I wanted to abbreviate "Interactive
Data Language" to IDL!? Amazing. :-)
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
|
Re: write unix textfile with windows idl [message #37736 is a reply to message #37725] |
Thu, 22 January 2004 02:00  |
Klemens Barfus
Messages: 45 Registered: December 2002
|
Member |
|
|
Thanks, but I got the answer now - I am using an old version of IDL,
which does not support c-style format :-(
Klemens
Pepijn Kenter wrote:
>
>
> Klemens Barfus wrote:
>
>> Hi Michael,
>> testing your code I got:
>>
>> % "(%"%s\n")"
>> % ^
>> % Unexpected text in format.
>>
>
> Because you want a string with quotes in it, you must use single and
> double quotes mixed:
>
> '(%"%s\n")'
>
> Pepijn.
>
|
|
|
|
Re: write unix textfile with windows idl [message #37738 is a reply to message #37737] |
Thu, 22 January 2004 01:09  |
Klemens Barfus
Messages: 45 Registered: December 2002
|
Member |
|
|
Hi Michael,
testing your code I got:
% "(%"%s\n")"
% ^
% Unexpected text in format.
I am not familar with C-style format code, any suggestions ?
Thanks in advance !
Klemens
Michael Wallace wrote:
>> A work-around is to use writeu in stead of printf and use the string
>> procedure to format the text, i.e. to write some text and a number, the
>> following code works
>>
>> writeu, 1, String( "Hello word, the year is", 2004), 10B
>>
>> but looks ugly. Any other ideas?
>
>
>
> You can use the format keyword of the string function to add a C-style
> control character to the string. For UNIX, just add \n (newline) to the
> end of your string. For Windows, add \r\n (carriage return and newline).
>
> ; UNIX version
> writeu, 1, string('Hello World', format = '(%"%s\n")')
>
> ; Windows version
> writeu, 1, string('Hello World', format = '(%"%s\r\n")')
>
|
|
|
|
Re: write unix textfile with windows idl [message #37740 is a reply to message #37739] |
Wed, 21 January 2004 10:31  |
Michael Wallace
Messages: 409 Registered: December 2003
|
Senior Member |
|
|
> A work-around is to use writeu in stead of printf and use the string
> procedure to format the text, i.e. to write some text and a number, the
> following code works
>
> writeu, 1, String( "Hello word, the year is", 2004), 10B
>
> but looks ugly. Any other ideas?
You can use the format keyword of the string function to add a C-style
control character to the string. For UNIX, just add \n (newline) to the
end of your string. For Windows, add \r\n (carriage return and newline).
; UNIX version
writeu, 1, string('Hello World', format = '(%"%s\n")')
; Windows version
writeu, 1, string('Hello World', format = '(%"%s\r\n")')
|
|
|
Re: write unix textfile with windows idl [message #37744 is a reply to message #37740] |
Wed, 21 January 2004 08:56  |
Norbert Hahn
Messages: 46 Registered: May 2003
|
Member |
|
|
Klemens Barfus <klemens.barfus@forst.tu-dresden.de> wrote:
> Hello together,
> it seems to be a quite easy problem but I would like to write unix text
> files with idl operating under windows.
HM, I played a little and came up with some text the online help:
"The Windows-Only keywords BINARY and NOAUTOMODE are now obsolete. Input/Output
on Windows is now handled indentically to Unix, and does not require you to be
concerned about the difference between "text" and "binary" modes. These keywords
are still accepted for backwards compatibility, but are ignored."
Those keywords are ignored causing lines written with the printf command
are terminated by carriage return and line feed when Windows is the OS
and line feed only for Unix. Thus "handled indentically to Unix" is at
least hard to understand.
>
> How can I manage these ?
A work-around is to use writeu in stead of printf and use the string
procedure to format the text, i.e. to write some text and a number, the
following code works
writeu, 1, String( "Hello word, the year is", 2004), 10B
but looks ugly. Any other ideas?
Norbert
|
|
|