Setting the value of a button hilite in script

Phil Davis revdev at pdslabs.net
Tue Dec 13 20:43:03 EST 2011


Hi Pete,

I'm not always good at staying on-topic, but maybe some of this will help...

On 12/13/11 2:50 PM, Pete wrote:
> I wrote myself a script to set the initial values of controls on a card in
> preOpenCard.  It looks for a custom property name cInitialValue, then
> initialises the control to the value of the custom property, depending on
> that type of control (field, button, etc).
>
> I set the value of cInitialValue for checkboxes or radio buttons to either
> true or false. My code then is:
>
> set the hilite of control x of this card to (the cInitialValue of control x
> of this card)
>
> At run time, I get an error  - value is not a boolean (true or false) near
> "false"

Couple of things:

- since only buttons can have hilites, why not make your 'set' loop deal with 
buttons only? e.g. "set the hilite of btn x of ...."

- an easy way to handle empty cprop hilite values (assuming empty = false) is:
     set the hilite of btn x of this card to (the cInitialValue of btn x of this 
card = true)
Doing this will prevent runtime hilite-setting errors (though your hilites may 
still not be set to the correct values)
>
> I'm suspecting this is because true and false are reserved words but the
> set statement is treating them as literals (they are not in quotes in the
> cprop though).  However, the statement:
>
> put  (the cInitialValue of control x of this card) into control x of this
> card
>
> ...works just fine when the value of the cprop is the word empty, also a
> reserved word.
Right - buttons can contain text, so you can put empty or other text into them 
without an error.

>
> I'm reduced to what looks like a nonsenical if statement that checks the
> cprop for true or false and sets the hilite of the button to true or false.
>   Looks really weird!

Wait until you get or set the text of an image! That always makes me squirm.
>
I've meddled enough for now...

-- 
Phil Davis

PDS Labs
Professional Software Development
http://pdslabs.net





More information about the use-livecode mailing list