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

Home » Public Forums » archive » FORMAT question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: FORMAT question [message #65890 is a reply to message #27063] Fri, 27 March 2009 08:46 Go to previous message
David Fanning is currently offline  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.")
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: FORMAT question
Next Topic: IDL & ENVI error: WIDGET_CONTROL: Invalid widget identifier: 17

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

Current Time: Fri Oct 10 12:42:33 PDT 2025

Total time taken to generate the page: 0.48192 seconds