PDA

View Full Version : Can a checkbutton return a value?



Maspalio
December 14th, 2019, 13:29
Hi all,


I'm in trouble with a ruleset modification. To represent the different levels of a heathbar, i have five labels and a check type button associated at the end of each lines. Fresh, Weary, Tired, Dazed, and so on.

What i want to do is when the checkon state is activated, it returns the value "1", so i can use this in a subsequent field to calculate the right penalty. i.e. tired = 1 for checked button x (-3 for tired state) = -3

Actually i have a stringfield where i write "1". Can i swap it to a checkbox and have the "1" still counted? And how to do that?

Or to simplify, have the right penalty ported over when the button is checked. i.e tired = -3

Thanks by advance.

Moon Wizard
December 14th, 2019, 20:31
A buttonfield is stored as a number in the database. If it has more than one state, then the states will be numbers from 0 to n-1, where n is the number of button states. You can use getValue() and setValue() on a button control to retrieve or set the state.

You'll need to make sure that you work through the logic that you are trying to accomplish so that the data stored in the database is what you expect, and the fields that you are displaying to the user will update as you expect.

I was not able to understand exactly what you want to do, based on your description; so I can't be more specific.

Regards,
JPG

damned
December 14th, 2019, 23:38
If all your calculations are multiplications the 1 is irrelevant.
If check box is ticked and tired then penalty = -3

Maspalio
December 15th, 2019, 08:31
Thanks to both of you, it was helpful.