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

Home » Public Forums » archive » Re: Setting odd/even numbers and decimal places in ENVI widgets
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: Setting odd/even numbers and decimal places in ENVI widgets [message #65623] Sat, 14 March 2009 16:33
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
a.l.j.ford@gmail.com writes:

> I'm currently using widget_slider (and widget_sslider), but I need to
> constrain them to only odd numbers (so I can set the kernel size for
> processing later in my User Function). How does one make sure that
> such widgets only return (and display) either odd or even numbers?

Capture the event that changes the widget value and then
check to see if the value is odd or not, (value MOD 2) EQ 0. If
it is even, add one to it and make this the new value
of the slider.


> In a similar fashion I'm using cw_fslider and need to return numbers
> with just one or two decimal places. How can I make sure the widget
> only displays (and returns) numbers with such few decimal places?

I find Number_Formatter to be useful for formatting numbers
when I am working with widgets:

http://www.dfanning.com/programs/number_formatter.pro

But something like this:

number = 35.345638
num = String(Round(number*100)/100., Format='(F0.2)')
print, num

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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Setting odd/even numbers and decimal places in ENVI widgets
Next Topic: Re: Using contour in postscripts produces a "stripe" effect?

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

Current Time: Wed Oct 08 19:39:41 PDT 2025

Total time taken to generate the page: 0.00557 seconds