Is it possible to affect radiobutton selection with DoAlert?

Hello.

I have a problem combining DoAlert and radiobuttons.

When I change between two radio button, then I want to have a question prompted which need to be answered with yes or no. If the answer is yes, then the clicked radio button should be selected. But if the answer is no, then the previous selected radio should stay selected. My current problem is when I press no than both radio buttons are selected.

Here is my code.

Function sampling_method_proc(cb):CheckboxControl
    STRUCT WMCheckboxAction &cb
   
    switch(cb.eventCode)
        case 2:                 // Mouse up
            sampling_method_proc_extra(cb.ctrlname)
            break
    endswitch
 
    PanelApp()                  //activates function for enable/disable parts of panel
End


Function sampling_method_proc_extra(controlname)
     String controlname
    NVAR SamplingMethodG=root:SamplerGlobals:SamplingMethodG
   
   
    DoAlert/T="Active Checkbox" 1,"Are all Active Checkboxes unchecked?"
   
    if (V_flag==1)
        strswitch (controlname)
            case "sampling_automatic_panel":
            SamplingMethodG=1
            break
           
            case "sampling_manual_panel":
            SamplingMethodG=2
            break
        endswitch
    else
        return 0
    endif
   
       
End

 

Thank you in advance.

 

Function sampling_method_proc(cb):CheckboxControl
    STRUCT WMCheckboxAction &cb
   
    switch(cb.eventCode)
        case 2:                 // Mouse up
            sampling_method_proc_extra(cb.ctrlname)
            break
    endswitch
   
   // be careful here - PanelApp() is executed for EVERY event.
   // you should choose the events that allow execution to reach this point
    PanelApp()                  //activates function for enable/disable parts of panel

End


Function sampling_method_proc_extra(controlname)
     String controlname
    NVAR SamplingMethodG=root:SamplerGlobals:SamplingMethodG
   
   
    DoAlert/T="Active Checkbox" 1,"Are all Active Checkboxes unchecked?"
   
    if (V_flag==1)
        strswitch (controlname)
            case "sampling_automatic_panel":
            SamplingMethodG=1
            break
           
            case "sampling_manual_panel":
            SamplingMethodG=2
            break
        endswitch
    else
       
      // you arrive here when you click "no",
      // so set the global variables associated with the checkboxes as you wish
      return 0

    endif
   
       
End

 

In reply to by neovenecia

neovenecia wrote:

But how shall I set them that there is no change in the selection of the radio button?

you can pass the name of the checkbox that was clicked and its value from the checkbox procedure, then figure out the logic of whatever you want to do.

if g is the global variable associated with the checkbox that was clicked you will probably want to set g=!g

In reply to by neovenecia

neovenecia wrote:

But how shall I set them that there is no change in the selection of the radio button?

 

Perhaps what you are looking for is the "value" keyword for the CheckBox control.  For details look up Checkbox in Command Help.