comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: write unix textfile with windows idl
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: write unix textfile with windows idl [message #37722] Thu, 22 January 2004 10:16
David Fanning is currently offline  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 Go to previous message
David Fanning is currently offline  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 #37725 is a reply to message #37723] Thu, 22 January 2004 09:11 Go to previous message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
> % "(%"%s\n")"
> % ^
> % Unexpected text in format.
>
> I am not familar with C-style format code, any suggestions ?
>

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
Re: write unix textfile with windows idl [message #37736 is a reply to message #37725] Thu, 22 January 2004 02:00 Go to previous message
Klemens Barfus is currently offline  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 #37737 is a reply to message #37736] Thu, 22 January 2004 01:53 Go to previous message
Pepijn Kenter is currently offline  Pepijn Kenter
Messages: 31
Registered: April 2002
Member
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 Go to previous message
Klemens Barfus is currently offline  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 #37739 is a reply to message #37738] Wed, 21 January 2004 23:54 Go to previous message
Klemens Barfus is currently offline  Klemens Barfus
Messages: 45
Registered: December 2002
Member
OK, I will try your suggestions.
Thanks for your help !

Klemens
Re: write unix textfile with windows idl [message #37740 is a reply to message #37739] Wed, 21 January 2004 10:31 Go to previous message
Michael Wallace is currently offline  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 Go to previous message
Norbert Hahn is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: again strsplit
Next Topic: Strange widget_info(FIND_BY_UNAME...) results

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:48:27 PDT 2025

Total time taken to generate the page: 0.06840 seconds