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
Radio
- MarcoBoschi
- Posts: 1072
- Joined: Thu Nov 17, 2005 11:08 am
- Location: Padova - Italy
- Contact:
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Radio
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
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
- MarcoBoschi
- Posts: 1072
- Joined: Thu Nov 17, 2005 11:08 am
- Location: Padova - Italy
- Contact:
Re: Radio
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
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
info@marcoboschi.it
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Radio
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
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
- MarcoBoschi
- Posts: 1072
- Joined: Thu Nov 17, 2005 11:08 am
- Location: Padova - Italy
- Contact:
- MarcoBoschi
- Posts: 1072
- Joined: Thu Nov 17, 2005 11:08 am
- Location: Padova - Italy
- Contact:
Re: Radio
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
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
info@marcoboschi.it
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Radio
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
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
- MarcoBoschi
- Posts: 1072
- Joined: Thu Nov 17, 2005 11:08 am
- Location: Padova - Italy
- Contact:
Re: Radio
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
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
info@marcoboschi.it