• 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. hiCreateListBoxField,callBack

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 143
  • Views 2780
  • 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

hiCreateListBoxField,callBack

sritha
sritha over 6 years ago

Hi Andrew,

 I have created the ListBoxField

box=hiCreateListBoxField(?name box

                                                 ?choices '("pfets" "nfets" "res")

                                                  ?callback "")

for the given choices  I need to trigger different  functions for each choice list.  Example: if  Iselect pfets in the appeared listbox field then it has to trigger pfets() function and  if I select nfets then it has to trigger nfets() function and so on. (pfets() and nfets() are user defined functions)  How to achieve this using callback?

  • Cancel
Parents
  • mbracht
    mbracht over 6 years ago

    Hi,

    well even I'am not Andrew ;-) I think I can answer this. The information about the selected item is available in the listbox callback so from there you may dispatch the required function:

    box=hiCreateListBoxField(
       ?name 'box
       ?choices '("pfets" "nfets" "res")
       ?callback (lambda (@rest args)
             (case (car (car args)->value)
                ("pfets"
                   (pfets)
                )
                ("nfets"
                   (nfets)
                )
                ("res"
                (res)
                )
             )
             t
          )
       )

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • mbracht
    mbracht over 6 years ago

    Hi,

    well even I'am not Andrew ;-) I think I can answer this. The information about the selected item is available in the listbox callback so from there you may dispatch the required function:

    box=hiCreateListBoxField(
       ?name 'box
       ?choices '("pfets" "nfets" "res")
       ?callback (lambda (@rest args)
             (case (car (car args)->value)
                ("pfets"
                   (pfets)
                )
                ("nfets"
                   (nfets)
                )
                ("res"
                (res)
                )
             )
             t
          )
       )

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • Andrew Beckett
    Andrew Beckett over 6 years ago in reply to mbracht

    I'm struggling to get a post to reply to this thread to work - I had a slightly simpler way of doing what Max suggested. I'm working with our IT to figure out why my post won't go through.

    Andrew

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

    Hopefully the post will work this time.

    One approach is this:

    procedure(MyListBoxCB()
      let((box)
        box=car(hiGetListBoxValue(hiGetCurrentForm()->box))
        when(box
          errset(funcall(concat(box) /*... extra args to function here ... */ ) t)
        )
     )
    )

    Then change the callback to "MyListBoxCB()". This code retrieves the selected value from the field (only the first, because I'm assuming only single selection is enabled), then converts to a symbol and calls the function with that name using funcall. I wrapped it with an errset in order to catch any errors triggered during the function call and display them.

    A second alternative is using something similar to the approach that Max took but putting the function directly in the callback (i.e. using a lambda to avoid having a named function):

    box=hiCreateListBoxField(
      ?name 'box
      ?choices '("pfets" "nfets" "res")
      ?callback lambda((field scope)
        errset(funcall(concat(car(hiGetListBoxValue(field)))) t)
      )
    )


    By the way, I'm not the only person here, so best not to post questions assuming that it is only me that will answer!

    Regards,

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • sritha
    sritha over 6 years ago in reply to mbracht

    Hi,

       I tried with your snippet,but it was showing error as Error : eval not a function "pfets".

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago in reply to sritha

    Er, that's because you haven't defined a function called pfets! You said that there were user-defined functions called pfets, nfets, res etc. If you do:

    procedure(pfets() printf("HELLO pfets\n"))
    procedure(nfets() printf("HELLO nfets\n"))
    procedure(res() printf("HELLO res\n"))

    The code is simply trying to call the function and if it doesn't exist, it gives an error. If you only want to call the function if it exists, you could do:

    box=hiCreateListBoxField(
      ?name 'box
      ?choices '("pfets" "nfets" "res")
      ?callback lambda((field scope)
        letseq(
          ((value car(hiGetListBoxValue(field))) (funcName value && concat(value)))
          when(funcName && isCallable(funcName)
            errset(funcall(concat(car(hiGetListBoxValue(field)))) t)
          )
        )
      )
    )

    This also checks that a value was specified (the earlier value did that, but I omitted it from the inline version - this can happen if you use ctrl-click to deselect any item in the listbox).

    Andrew.

    • 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