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

Home » Public Forums » archive » Re: FORMAT question
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: FORMAT question [message #27040] Sun, 07 October 2001 23:52
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Paul van Delst wrote:
>
> Reimar Bauer wrote:
>>
>> Paul Manusiu wrote:
>>>
>>> Hi,
>>> Does anyone if its possible to use a function or variable as a parameter
>>> or option to FORMAT ?
>>> ;e.g. if I have
>>> print, blah, FORMAT = '(2(F6.1))'
>>> ; but I want something like this
>>> for var = 0, 10 do $
>>> print, blah[var,*], FORMAT = '(var(F6.1))'
>>>
>>> Any help please will be much appreciated
>>>
>>> Paul M.
>>
>> Dear Paul,
>>
>> this is the first time I am able to give totally the same answer
>> to someone in this newsgroup at the same day. Don't you read others
>> articles?
>
> Actually your reply doesn't directly apply to the problem he's having - i.e. a repreat
> specifier in a format statements - although your software might.
>


I agree, I have not seen this problem. The routine could be useful too
if you don't
know anything about the format of the data.

The online help with the keyword "Format codes" describes much more
formatting codes
and syntax.

Reimar


> In any case, apart from Andrew's solution, I would also try:
>
> IDL> var=2
> IDL> fmt='('+strtrim(var,2)+'(f6.1))'
> IDL> print, fmt
> (2(f6.1))
>
> to avoid the need for _another_ format when outputting var into the format string.
>
> paulv
>
> --
> Paul van Delst Religious and cultural
> CIMSS @ NOAA/NCEP purity is a fundamentalist
> Ph: (301)763-8000 x7274 fantasy
> Fax:(301)763-8545 V.S.Naipaul

--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml

http://www.fz-juelich.de/zb/text/publikation/juel3786.html
============================================================ ======

read something about linux / windows
http://www.suse.de/de/news/hotnews/MS.html
Re: FORMAT question [message #27049 is a reply to message #27040] Fri, 05 October 2001 12:45 Go to previous message
Phillip David is currently offline  Phillip David
Messages: 36
Registered: April 1999
Member
try the even simpler command:
x = findgen(10)*!pi
print, x, format='(' + strtrim(n_elements(x),2) + '(f10.6))'

This will print out all elements on a single line.

As an additional note, if you use print, x, format='((f10.6))', you'll
get each element printed on its own line, but they still all get
printed. More useful, perhaps, is the idea that you can get an
appropriate line length this way.

x = findgen(1000)*!pi
print, x, format='(10(f10.6))'

will give you 100 lines with 10 elements each on them.

You probably knew this, but there may have been some who didn't.

Phillip

Paul Manusiu wrote:
>
> Hi,
> Does anyone if its possible to use a function or variable as a parameter
> or option to FORMAT ?
> ;e.g. if I have
> print, blah, FORMAT = '(2(F6.1))'
> ; but I want something like this
> for var = 0, 10 do $
> print, blah[var,*], FORMAT = '(var(F6.1))'
>
> Any help please will be much appreciated
>
> Paul M.
Re: FORMAT question [message #27056 is a reply to message #27049] Fri, 05 October 2001 08:11 Go to previous message
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
Reimar Bauer wrote:
>
> Paul Manusiu wrote:
>>
>> Hi,
>> Does anyone if its possible to use a function or variable as a parameter
>> or option to FORMAT ?
>> ;e.g. if I have
>> print, blah, FORMAT = '(2(F6.1))'
>> ; but I want something like this
>> for var = 0, 10 do $
>> print, blah[var,*], FORMAT = '(var(F6.1))'
>>
>> Any help please will be much appreciated
>>
>> Paul M.
>
> Dear Paul,
>
> this is the first time I am able to give totally the same answer
> to someone in this newsgroup at the same day. Don't you read others
> articles?

Actually your reply doesn't directly apply to the problem he's having - i.e. a repreat
specifier in a format statements - although your software might.

In any case, apart from Andrew's solution, I would also try:

IDL> var=2
IDL> fmt='('+strtrim(var,2)+'(f6.1))'
IDL> print, fmt
(2(f6.1))

to avoid the need for _another_ format when outputting var into the format string.

paulv

--
Paul van Delst Religious and cultural
CIMSS @ NOAA/NCEP purity is a fundamentalist
Ph: (301)763-8000 x7274 fantasy
Fax:(301)763-8545 V.S.Naipaul
Re: FORMAT question [message #27057 is a reply to message #27056] Fri, 05 October 2001 07:13 Go to previous message
Paul Manusiu is currently offline  Paul Manusiu
Messages: 8
Registered: October 2001
Junior Member
Thanks Andrew it did the job just fine.
Re: FORMAT question [message #27060 is a reply to message #27057] Fri, 05 October 2001 05:15 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Paul Manusiu wrote:
>
> Hi,
> Does anyone if its possible to use a function or variable as a parameter
> or option to FORMAT ?
> ;e.g. if I have
> print, blah, FORMAT = '(2(F6.1))'
> ; but I want something like this
> for var = 0, 10 do $
> print, blah[var,*], FORMAT = '(var(F6.1))'
>
> Any help please will be much appreciated
>
> Paul M.

Dear Paul,

this is the first time I am able to give totally the same answer
to someone in this newsgroup at the same day. Don't you read others
articles?


we have some routines which returns the format code of a value


http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_ html/dbase/download/find_form.tar.gz

; EXAMPLE:
; numbers=[100,2.1345,1000.]
; print,find_form(numbers)
; F10.4
; print,find_form(numbers,/reduce_accuracy)
; F10.2
; print,find_form(-40010138.D)
; I9
; print,find_form(-40010138.D,/force)
; F10.0

http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_ html/dbase/download/number_format.tar.gz


For further routines and licensing please have a look at
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml


regards
Reimar
--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml

http://www.fz-juelich.de/zb/text/publikation/juel3786.html
============================================================ ======

read something about linux / windows
http://www.suse.de/de/news/hotnews/MS.html
Re: FORMAT question [message #27062 is a reply to message #27060] Fri, 05 October 2001 03:55 Go to previous message
A. D. & J.C. Cool is currently offline  A. D. & J.C. Cool
Messages: 16
Registered: February 2000
Junior Member
Paul Manusiu wrote:

> Hi,
> Does anyone if its possible to use a function or variable as a parameter
> or option to FORMAT ?
> ;e.g. if I have
> print, blah, FORMAT = '(2(F6.1))'
> ; but I want something like this
> for var = 0, 10 do $
> print, blah[var,*], FORMAT = '(var(F6.1))'
>
> Any help please will be much appreciated
>
> Paul M.

Hi Paul,

Try building up your format string :-


> IDL> var = 2
> IDL> format_str='('+ string(var,form='(i2)') + '(f6.1))'
> IDL> print,format_str
> ( 2(f6.1))
> IDL> y=[1254.643,643.804]
> IDL> print,y,format=format_str
> 1254.6 643.8
>

There's probably a kosher way of doing this, but hey, it works...

Andrew Cool
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL 5.4 and win2000 problems: Windows IDLDE crash poll
Next Topic: How to run a exe program?

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

Current Time: Wed Oct 08 11:43:34 PDT 2025

Total time taken to generate the page: 0.00603 seconds