FORMAT question [message #27063] |
Fri, 05 October 2001 00:06  |
Paul Manusiu
Messages: 8 Registered: October 2001
|
Junior Member |
|
|
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 #65889 is a reply to message #27063] |
Fri, 27 March 2009 08:56  |
natha
Messages: 482 Registered: October 2007
|
Senior Member |
|
|
Thanks David,
You are always available to answer the questions.
With FORMAT='(e0.1)' it's enough for me ! I didn't know this
convertion format.
Thanks !
llo
|
|
|
Re: FORMAT question [message #65890 is a reply to message #27063] |
Fri, 27 March 2009 08:46  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
llo writes:
> Hi folks,
>
> I used to use the Embedded Formatting Commands to print strings with a
> nice format, know I've a question.
> I've the following float: 65465.45
>
> And I want to represent it as a string in a IDLgrText object.
> The result I want is something like this:
> aa=OBJ_NEW('IDLgrText',STRING='6.5x10!U4',/ENABLE_FORMATTING )
> XOBJVIEW, aa
>
> My "problem" is that I don't know how to convert it as a string using
> the FORMAT KEYWORD of the STRING FUNCTION.
> I mean, I want to use a code like this:
> f=65465.45
> aa=OBJ_NEW('IDLgrText',STRING=STRING(f,FORMAT='xxxxxxx'),/
> ENABLE_FORMATTING)
> XOBJVIEW, aa
>
> And I need the an expression 'xxxxxxxx' in order to obtain my result.
> Any suggestions?
How about this:
FUNCTION times10, number
n = String(number, FORMAT='(e0.1)')
e = StrPos(n, 'e')
IF e EQ -1 THEN RETURN, n
theNumber = StrMid(n, 0, e) + ' x 10!U4'
RETURN, theNumber
END
f = 65465.45
str = Obj_New('IDLgrText', Times10(f), /Enable_formatting)
xobjview, str
END
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|