• 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
  • 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
Reply
  • 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
Children
No Data

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