Page 1 of 1

checkbox FIELD property does not update the field

Posted: Fri Jul 02, 2010 3:16 pm
by raumi75
Hello everyone,

sorry for not posting for so long. I have been busy with other projects but now I am back with my favorite programing language: HMG!

I noticed a strange behavior of the checkbox.

I used the FIELD-property and expected it to work just like in a TEXTBOX-control. It reads the value from the database field and when the user updates the control, the database field gets changed, too.

Code: Select all

FIELD db->field
But in CHECKBOX, it displays the correct value (true = checked / false= unchecked) as it is saved in the database. But when I click to check or uncheck it, the database value does not get changed.

I have to do this by hand by supplying an ON CHANGE command.

Code: Select all

ONCHANGE db->field := this.value
Am I doing something wrong or is this a bug in HMG?

Yours

Raumi

Re: checkbox FIELD property does not update the field

Posted: Sat Jul 03, 2010 2:03 am
by Roberto Lopez
raumi75 wrote:Hello everyone,

sorry for not posting for so long. I have been busy with other projects but now I am back with my favorite programing language: HMG!

I noticed a strange behavior of the checkbox.

I used the FIELD-property and expected it to work just like in a TEXTBOX-control. It reads the value from the database field and when the user updates the control, the database field gets changed, too.

Code: Select all

FIELD db->field
But in CHECKBOX, it displays the correct value (true = checked / false= unchecked) as it is saved in the database. But when I click to check or uncheck it, the database value does not get changed.

I have to do this by hand by supplying an ON CHANGE command.

Code: Select all

ONCHANGE db->field := this.value
Am I doing something wrong or is this a bug in HMG?

Yours

Raumi
Welcome again.

I'll check it ASAP.

Re: checkbox FIELD property does not update the field

Posted: Sat Jul 03, 2010 8:41 am
by esgici
Hi Raumi

Are you sure in this sentence :

Code: Select all

ONCHANGE db->field := this.value
db is alias of your database file ?

If not, may be this is the problem.

Also, AFAIK FIELD is a reserved word and using it as a field name may be causing problem.

Moreover you may try REPLACE command or FIELDPUT() function instead of assignment operator ( := ) for changing content of a database file fields.

Regards

--

Esgici

Re: checkbox FIELD property does not update the field

Posted: Sat Jul 03, 2010 9:28 am
by raumi75
esgici wrote:Hi Raumi

Are you sure in this sentence :

Code: Select all

ONCHANGE db->field := this.value
db is alias of your database file ?

If not, may be this is the problem.

Esgici
No. This not the real code. Just an example to show, what I did. The real code has variables in German, so I tried to simplify it a little bit.

The ONCHANGE event does the trick and my program runs fine.

It is just, that for other hmg-controls, the FIELD property also updates the database field and I don't have to write any ONCHANGE method. So if it is not a bug, it is at least a little inconsistent. And we know, how much Roberto loves consistency and simplicity. So I thought this worth mentioning.

Maybe Roberto can reproduce my error.

Raumi

Re: checkbox FIELD property does not update the field

Posted: Sat Jul 03, 2010 10:17 am
by esgici
Hi Raumi

Sorry, I'm misunderstood your question :(

And, checked <hmg>\SAMPLES\DATA.BOUND\datacontrols.prg :

We need separate "save" method each data.bound control for saving changed field value/content to database file.

Simply navigate (next/previous...) between records doesn't save data.

I don't know you have already done this.

Regards

--

Esgici

Re: checkbox FIELD property does not update the field

Posted: Sat Jul 03, 2010 11:59 am
by raumi75
esgici wrote:Hi Raumi

Sorry, I'm misunderstood your question :(

And, checked <hmg>\SAMPLES\DATA.BOUND\datacontrols.prg :

We need separate "save" method each data.bound control for saving changed field value/content to database file.

Simply navigate (next/previous...) between records doesn't save data.

I don't know you have already done this.

Regards

--

Esgici
Thank you for pointing me to the DATA.BOUND samples. I am now playing with it.

If you add dbcommit() to the SAVE procedure, it stores your changes in the database.

Surprisingly, the TEXTBOX and CHECKBOX behave the same in the sample. I think, I will have to take a closer look at my own code. I hope, I am not wasting your time.

Raumi

Re: checkbox FIELD property does not update the field

Posted: Sat Jul 03, 2010 12:15 pm
by esgici
raumi75 wrote: ...
I hope, I am not wasting your time.
Absolutely no, my friend, everything is for HMG and HMG community :D

Regards

--

Esgici

Re: checkbox FIELD property does not update the field

Posted: Sat Jul 03, 2010 1:34 pm
by raumi75
OK. I have found my bug. HMG works fine. Sorry for this post.

Thanks giving me the right hints!!

Raumi

Re: checkbox FIELD property does not update the field

Posted: Sat Jul 03, 2010 3:48 pm
by Roberto Lopez
raumi75 wrote:OK. I have found my bug. HMG works fine. Sorry for this post.

Thanks giving me the right hints!!

Raumi
No problem and congratulations for your great victory!!!

And thanks for the help Esgici.