• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. Radio button changes automatically

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 143
  • Views 10037
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Radio button changes automatically

seongminlee
seongminlee over 3 years ago

1. I want to make a radio button that changes automatically.
When you check test1, test2, test3 of MENU1, test1 test2 tset3 of MENU2 should follow automatically

2. ?choices Choices1 

When using Choices1 as a list, an error occurs.
Can you guess the cause?

------attached code----

let( (radiofield1 radiofield2)
radiofield1 = hiCreateRadioField(
?name 'radio1
?prompt "MENU1"
?value "test1"
?choices '("test1" "test2" "test3" "test4" "test5")
)
radiofield2 = hiCreateRadioField(
?name 'radio2
?prompt "MENU2"
?value "test1"
?choices '("test1" "test2" "test3")
)
;Choices1 = '("test1" "test2" "test3" "test4" "test5")
;Choices2 = '("test1" "test2" "test3")


hiDisplayForm(
hiCreateAppForm( ?name 'myform ?formTitle "Radio Button Test"
?fields (list radiofield1 radiofield2))
)

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago
    seongminlee said:

    Can you guess the cause?

    Not really, because you didn't show the code that had the error. Maybe you had ?choices 'Choices1 (i.e. were quoting the variable), which would be wrong, or maybe it was because you set the variable after you used it?

    Anyway, here's the code working using the variables for the choices, plus a callback which does what you asked for in point 1.

    Choices1 = '("test1" "test2" "test3" "test4" "test5")
    Choices2 = '("test1" "test2" "test3")
    
    procedure(CCFsetMenu2FromMenu1(form)
      when(member(form->radio1->value form->radio2->choices)
        form->radio2->value=form->radio1->value
      )
    )
    
    let( (radiofield1 radiofield2) 
      radiofield1 = hiCreateRadioField(
        ?name 'radio1 
        ?prompt "MENU1"
        ?value "test1"
        ?choices Choices1
        ?callback list("CCFsetMenu2FromMenu1(hiGetCurrentForm())")
      )
      radiofield2 = hiCreateRadioField(
        ?name 'radio2 
        ?prompt "MENU2"
        ?value "test1"
        ?choices Choices2
      )
    
      hiDisplayForm(
        hiCreateAppForm( ?name 'myform ?formTitle "Radio Button Test"
          ?fields (list radiofield1 radiofield2))
      )
    )

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • seongminlee
    seongminlee over 3 years ago in reply to Andrew Beckett

    Thank you very much.

    one more question. 

    ----------------------------------------------------------------------

    Choices1 = '("test1" "test2" "test3" "test4" "test5")
    Choices2 = '("test1" "test2" "test3")

    procedure(CCFsetMenu2FromMenu1(form)
    when(member(form->radio1->value form->radio2->choices)
    form->radio2->value=form->radio1->value
    )
    )

    let( (radiofield1 radiofield2 radiofield3 radiofield4 )
    radiofield1 = hiCreateRadioField(
    ?name 'radio1
    ?prompt "MENU1"
    ?value "test1"
    ?choices Choices1
    ?callback list("CCFsetMenu2FromMenu1(hiGetCurrentForm())")
    )
    radiofield2 = hiCreateRadioField(
    ?name 'radio2
    ?prompt "MENU2"
    ?value "test1"
    ?choices Choices1
    )
    radiofield3 = hiCreateRadioField(
    ?name 'radio3
    ?prompt "MENU3"
    ?value "test1"
    ?choices Choices1
    )
    radiofield4 = hiCreateRadioField(
    ?name 'radio4
    ?prompt "MENU4"
    ?value "test1"
    ?choices Choices2
    )

    hiDisplayForm(
    hiCreateAppForm( ?name 'myform ?formTitle "Radio Button Test"
    ?fields (list radiofield1 radiofield2 radiofield3 radiofield4))
    )
    )

    ------------------------------------------------------------------------------------

    With the above code, Menu1 Menu2 Menu3 should always select the same radio value.
    Menu4 has values of Menu1,2,3
    test1-> test3
    test2-> test3
    test3-> test2
    test4-> test1
    test5-> test1
    How do I make a selection like this?

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to seongminlee

    Rather odd requirement, but this is just a matter of having the appropriate callback logic. The code below means that whenever you set a value of the MENU1/MENU2/MENU3 radio buttons, it replicates the setting to the other two within the set, and then does a mapping to set MENU4. It's really not that complicated to do this - you just need to think about the logic you're trying to implement.

    Choices1 = '("test1" "test2" "test3" "test4" "test5")
    Choices2 = '("test1" "test2" "test3")
    
    procedure(CCFsetMenusFromMenuField(form field)
      let((fieldValue)
        fieldValue=get(form field)->value
        ; set the other fields to the value of the field just
        ; changed
        foreach(fieldName '(radio1 radio2 radio3)
          unless(fieldName==field
            when(member(fieldValue get(form fieldName)->choices)
              get(form fieldName)->value=fieldValue
            )
          )
        )
        ; set the final radio button with a mapping from the 
        ; chosen value using a case statement
        form->radio4->value=
          case(fieldValue
            (("test1" "test2") "test3")
            (("test3")         "test2")
            (("test4" "test5") "test1")
          )
        t
      )
    )
    
    let( (radiofield1 radiofield2 radiofield3 radiofield4 ) 
      radiofield1 = hiCreateRadioField(
        ?name 'radio1 
        ?prompt "MENU1"
        ?value "test1"
        ?choices Choices1
        ?callback list("CCFsetMenusFromMenuField(hiGetCurrentForm() 'radio1)")
      )
      radiofield2 = hiCreateRadioField(
        ?name 'radio2 
        ?prompt "MENU2"
        ?value "test1"
        ?choices Choices1
        ?callback list("CCFsetMenusFromMenuField(hiGetCurrentForm() 'radio2)")
      )
      radiofield3 = hiCreateRadioField(
        ?name 'radio3 
        ?prompt "MENU3"
        ?value "test1"
        ?choices Choices1
        ?callback list("CCFsetMenusFromMenuField(hiGetCurrentForm() 'radio3)")
      )
      radiofield4 = hiCreateRadioField(
        ?name 'radio4
        ?prompt "MENU4"
        ;?value "test1"
        ; changed default to match mapping logic
        ?value "test3"
        ?choices Choices2
      )
    
      hiDisplayForm(
        hiCreateAppForm( ?name 'myform ?formTitle "Radio Button Test"
          ?fields (list radiofield1 radiofield2 radiofield3 radiofield4)
        )
      )
    )
    
    
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information