[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nonexclusive button goup woes...



This is apparently an oversight in CW_FORM code. The program
CW_FORM_BUILD uses commas to separate fields in the descriptor elements.
Thus, a statement

desc[2] = '0, BUTTON, B1|B2|B3, LABEL_TOP=Nonexclusive:,
SET_VALUE=[1,1,1], COLUMN, TAG=bg1'

causes SET_VALUE to be equal to string "[1" (which can not be converted
to integer), and produces two unrecognized fields, "1" and "1]". So
using commas to define the array of states of the buttons is not going
to work. Besides that, the value does get passed to CW_BGROUP all right.
Setting SET_VALUE to a non-zero scalar value will successfully set the
first checkbox.

In order to trick the CW_FORM, try the following:

desc[2] = '2, button, option1|option2|option3|option4, set_value=indgen(4)

and checkboxes will get set. Now, use your oun creativity to come up
with some meaningful expression that will define an array but will not
use commas, and pass it into SET_VALUE, to set only those buttons you want.
Or, better yet, write plain and simple widget code without using
CW_FORM, which, as I'm looking at it for the second time ever, feels
like an unsucessful exercise in widget programming.
Cheers,
Pavel.


David Bowman wrote:
> 
> Hi all.  I have a (hopefully) simple question about the CW_FORM routine:
> 
> I'm creating a set of nonexclusive buttons, and I want to set the
> default values all at once using the set_value keyword...  The problem
> is, how do I set multiple values?  For example:
> 
> IDL>d=['1,base,,column',
>       '0, button, ok, quit',
>       '2, button, option1|option2|option3|option4, set_value=1 0 0 1']
> IDL>a=cw_form(desc,/column)
> 
> How do I make, for example, option1 and option4 set by default?  I've
> tried set_value=1001, set_value=[1,0,0,1], set_value=1|0|0|1 and
> various other combinations, but nothing seems to work...  Any ideas?
> 
> Thanks in advance.
> 
> --
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> David Bowman         "Smash forehead on keyboard to continue."
> Laboratoire Tectonique
> Institut de Physique du Globe - Paris
> 4 Place Jussieu
> 75252 Paris Cedex 05
> France