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

Home » Public Forums » archive » Re: Again: How to use FORMAT like sprintf??
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: Again: How to use FORMAT like sprintf?? [message #32225] Wed, 25 September 2002 07:24
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
Brian Huether wrote:
>
> I posted this question and got some great ansers but everytime I tried the
> examples that you all showed me, IDL gave me this error:
>
> Unexpected text in format
>
> I am using IDL 5.2. Could that be the problem? If so, can someone explain
> how to do what I need using version 5.2? Here is my original message:

I don't know when IDL started supporting C style format codes; it might
not have done so yet in 5.2. In that case, you'll need to learn to use
the Fortran-style format codes instead:

IDL> s = string(10, FORMAT= $
IDL> '("IDL has been driving me crazy for the last ",I0," days")' )
IDL> print,s
IDL has been driving me crazy for the last 10 days

IDL> arrayname='A'
IDL> somekeyword='TYPE'
IDL> s = string(arrayname, somekeyword, FORMAT= $
IDL> '("SIZE(",A0,", /",A0,")")' )
IDL> print,s
SIZE(A, /TYPE)

Just look in the online help, or your user's guide, for 'format codes'.
Re: Again: How to use FORMAT like sprintf?? [message #32232 is a reply to message #32225] Wed, 25 September 2002 02:03 Go to previous message
wmconnolley is currently offline  wmconnolley
Messages: 106
Registered: November 2000
Senior Member
Brian Huether <brian.huether@dlr.de> wrote:
> What I really need to do is something like this:

> s = sprintf('SIZE(%s, /%s)', arrayname, somekeyword)

> So if arrayname is A and somekeyword is TYPE, then the resulting string
> would be

> 'SIZE(A, /TYPE)'

So why not write

s='size('+arrayname+',/'+somekeyword+')'

-W.

--
William M Connolley | wmc@bas.ac.uk | http://www.nerc-bas.ac.uk/icd/wmc/
Climate Modeller, British Antarctic Survey | Disclaimer: I speak for myself
I'm a .signature virus! copy me into your .signature file & help me spread!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: What's better: 1 big HDF file or several samller ones??
Next Topic: TEST -- Ignore

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

Current Time: Wed Oct 08 19:44:12 PDT 2025

Total time taken to generate the page: 0.00489 seconds