How To set the content of a check box button in a script
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
How To set the content of a check box button in a script
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
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
Thanks, I think hilite is the answer, however now I have another problem.
The code I am using is:
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
The code I am using is:
Code: Select all
set the hilite of button "Active" to revDatabaseColumnNamed(gRsetID,"Active")
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
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
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
and ten use that in your script
HTH,
Jan Schenkel.
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
Code: Select all
set the hilite of button "Active" to SqlBoolean (revDatabaseColumnNamed(gRsetID,"Active"))
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
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
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