Page 1 of 1

How To set the content of a check box button in a script

Posted: Sun Jul 12, 2009 10:15 pm
by phaworth
I guess the Subject says it all. I'm reading data from a database. Some of the fields are boolean True/False and I need to set the value of check box buttons in a script to contain the value from the database entry and I don;t see how to do this.

I have a combobox button and it seems that setting the label property of that to a field from the database record makes the correct value show up in the combobox. If I do that with a check box button, the label of the check box on the screen just gets set to the numeric value of true or false.

I've tried "put ..... into button "checkBox" and "set button checkBox to..." but the former seems to have no effect and the latter gives me an error.

The User Guide is silent on this, at least as far as I can find.

I'm sure there is some simple way of doing this!

Pete

Posted: Sun Jul 12, 2009 10:31 pm
by bn
Hi phaworth,

how about:

set the label of button "myButton" to "myLabel"

?

regards
bernd

Posted: Sun Jul 12, 2009 11:09 pm
by malte
Hi pete,

I guess you are interested into the hilite property. Set the hilite of btn "mycheckbox" to true / false

Hth,

Malte

Posted: Mon Jul 13, 2009 12:46 am
by phaworth
Thanks, I think hilite is the answer, however now I have another problem.

The code I am using is:

Code: Select all

  set the hilite of button "Active" to revDatabaseColumnNamed(gRsetID,"Active")
This compiles OK but when it is executed, I get an error:

execution error at line n/a (Object: value is not a boolean (true or false)) near "0"

That last "0" is the value in the database field, which is always zero or 1. I think that's standard for databases (I'm using SQLite) but it seems that Revolution expects some other representation of true/false?

Pete

Posted: Mon Jul 13, 2009 6:00 am
by Janschenkel
Hi Pete,

Revolution is not a 'typed' language, and doesn't interpret 0 as 'false' and 1 as 'true' - you really have to pass true or false when you need a boolean value.
You can put a 'generic' function in your stack script

Code: Select all

function SqlBoolean pSqlValue
  return (pSqlValue is 1)
end SqlBoolean
and ten use that in your script

Code: Select all

set the hilite of button "Active" to SqlBoolean (revDatabaseColumnNamed(gRsetID,"Active"))
HTH,

Jan Schenkel.

Posted: Mon Jul 13, 2009 6:20 am
by phaworth
Thanks Jan, figured I'd have to do something like that.

On a separate issue, I need to cycle though the names of all the objects on a card and do some processing on each object depending on what type of object it is. There's another post from someone who told me how to get a count of the number of objects so I can use that as a control for the repeat loop but not seeing how to get the name of each object (and other properties) based on the iteration of the repeat loop.

This is my attempt to get round the bug in the Database Query builder that stops it working properly with SQLite dbs. My plan is to name each object the same as the db field it is linked to then write some routines which will load the db info into the fields and also update the db when the fields are changed. Painful but a lot less work than writing code specific to each field.

Pete

Posted: Mon Jul 13, 2009 6:35 am
by phaworth
Never mind - I think I figured it out.
Pete