FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Radio
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Radio
Posted: Wed Apr 07, 2010 12:47 PM

Hi,
when I click button oButton I set nRadio value to -1 then I perform a refresh of oRadio but nothing changes.

I expect to find the radio button in the initial state
Is there a solution?
Thanks
Marco

include "fivewin.ch"

FUNCTION MAIN

LOCAL oDlg
LOCAL oRadio , nRadio := -1
LOCAL oButton
LOCAL oSay, cSay := STR(nRadio,3)
DEFINE DIALOG oDlg

@ 2 , 10 BUTTON oButton ;
ACTION ( nRadio := -1 , ;
oRadio:Refresh() , ;
cSay := STR(nRadio,4) )

@ 1 , 1 RADIO oRadio VAR nRadio PROMPT "One " , "Two " OF oDlg ;
ON CHANGE ( cSay := STR(nRadio,3) , ;
oSay:refresh() )

@ 3 , 1 SAY oSay PROMPT cSay OF oDlg

ACTIVATE DIALOG oDlg

RETURN NIL

Marco Boschi
info@marcoboschi.it
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Radio
Posted: Wed Apr 07, 2010 01:10 PM

Marco,

I don't understand what you are trying to do.

You can't use a negative value. Try setting the initial value to 2, then set the value to 1 with the ACTION clause, and it works as expected.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Radio
Posted: Wed Apr 07, 2010 01:26 PM

Hi James,
thanks!

I need three state: 1 , 2 and another state that means empty
In the field of a dbf table these values become
IF nRadio = 1 cField := "YES"
IF nRadio = 2 cField := "NO"
IF nRadio = -1 cField := " "
-1 or another value
all here

Marco Boschi
info@marcoboschi.it
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Radio
Posted: Wed Apr 07, 2010 01:49 PM

Marco,

Radio's are designed to have default answer.

You could do what you want by adding a third option "Unknown" and then the radios would be 1, 2, and 3. You can then change the 3 to -1 when saving to the DBF.

I do agree with your philosophy of providing an unknown, blank, or unanswered option. Radios and checkboxes have a default answer which may not be valid if the user doesn't know the answer. This leads to bad information in the database and there is no way to know it is bad.

Providing an "Unknown" option and using it as the default is a good solution.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Radio
Posted: Wed Apr 07, 2010 01:52 PM

Ok,
thank you James

Marco

Marco Boschi
info@marcoboschi.it
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Radio
Posted: Wed Apr 07, 2010 02:39 PM

James,

in this way only "Yes" and "No" option are visible.

RADIOBUTTON "Yes", 1541, 348, 67, 20, 12
RADIOBUTTON "No", 1542, 370, 67, 22, 12
RADIOBUTTON "" , 1543, 396, 67, 22, 12, BS_RADIOBUTTON | NOT WS_VISIBLE

When I set oRadio:noption to 3 visually I obtain the initial state
Bye

Marco Boschi
info@marcoboschi.it
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Radio
Posted: Wed Apr 07, 2010 02:49 PM

Marco,

I advise against that. Once the user clicks on Yes or No, they cannot change their mind and then click on Unknown. This will still lead to some bad data in the database. Why not just leave it visible?

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Radio
Posted: Wed Apr 07, 2010 03:56 PM
James,
when a empty another field o set the value of radio to 3
in this way


oTVla:nCod_pro := 3
oTVla:oRadCod_pro:refresh()

...
...
REDEFINE RADIO oTVla:oRadCod_pro VAR oTVla:nCod_pro ;
ID 1541, 1542, 1543 OF oFld:aDialogs[ 5 ] ;
ON CHANGE oTVla:cCod_pro := IFM( oTVla:nCod_pro, { 3 , 1 , 2 } , {" " , "Yes" , "No" } )

...
...

FUNCTION IFM( xValore , aCondiz, aValori )
LOCAL i , xRitorna := NIL
FOR i := 1 TO LEN(aCondiz)
IF xValore = aCondiz[i]
xRitorna = aValori[i]
EXIT
ENDIF
NEXT i
RETURN xRitorna


It works
Bye
Marco Boschi
info@marcoboschi.it

Continue the discussion