Re: Setting odd/even numbers and decimal places in ENVI widgets [message #65623] |
Sat, 14 March 2009 16:33 |
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.")
|
|
|