• 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. Variable number of widgets

Stats

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

Variable number of widgets

Merfman
Merfman over 14 years ago

Hi, I just found this resource and couldn't be happier! 

I'm trying to create an application that reads a setup file and creates an input menu based on the number of entries in the setup file.  What I've attempted doesn't work.  Code snippet follows: 

 bButton = declare(bButton[20])
  i = 0
  while(i < iConnIndex
   bButton[i] = hiCreateBooleanButton(
    ?name 'bButton[i]
    ?buttonText "Use Layer:"
    ?callback "nil"
    ?value t
   );hCBB
  i++
 );while

 When I run this snippet, I get the following error message: 

*Error* hiCreateBooleanButton: argument for keyword ?name should be a symbol (type template = "sgggtggggs") - bButton[i]

 

So, my questions are open: 

1) Am I missing something simple or is this just not doable? 

2) Is there an established way of accomplishing the same and I'm just using the most difficult method? 

 

Any and all help would be greatly appreciated!  

Thanks in advance, 

Ken Murphy

 

  • Cancel
  • skillUser
    skillUser over 14 years ago

    Hi Ken,

    Hopefully it is something simple (1) - in your code you have 'bButton[i] - the single quote ' prevents the evaluation of anything that follows, so the array index would not evaluate.  I'm not sure why you declare an array for this, it should not be needed?  Anyway, one method to achieve what you want is to create the symbol for storing the button structure by using concat to join the name base and the integer to form the symbol name, e.g. concat('bButton i) - the "i" is unquoted so that it will evaluate to 0, 1, 2 etc.

    Another method (2) for creating unique symbol names that do not clash is to use gensym - this can be given a base name as in the above concat example: gensym('bButton) - so if you do not need to know or control the name of this symbol/variable, then this approach would work also.  Without more code context I don't know if this approach would suit your needs in this case.

    I hope this answers your question and helps you get this working.

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Merfman
    Merfman over 14 years ago

    Thanks Lawrence, that really does explain lots.  The reason I declared the array was to just be able to use arrays and declaring it fixed a different error.  I may be able to remove it.  All this code is currently just being hacked to see what I can do.  

     

    I'll give the concat a try... I'd tried unsuccessfully to use sprintf to accomplish the same but I think I had other issues that were masking the problem.  Thanks for the feedback, I'll definitely give it a try! 

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 14 years ago

    You could use sprintf(), but you'd need to convert it to a symbol afterwards. So something like stringToSymbol(sprintf(nil "button%d" i)) would do it - but concat('button i) is probably simpler!

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Merfman
    Merfman over 14 years ago

     Good point!  I did use sprintf tho and it seemed to work... code isn't complete so I probably would have found an issue later.  Thanks for the heads up Andrew!

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Merfman
    Merfman over 14 years ago

     SUCCESS!  After a few false starts, I was able to get the code to work.  Here's the new snippet: 

     procedure( createMenu()
      i = 0
      buttonList = '()
      while(i < iConnIndex
       nameVar = concat('bButton i)
       sprintf(buttonText "Use layer %s" iConn[i])
        nameVar = hiCreateBooleanButton(
        ?name nameVar
        ?buttonText buttonText
        ?callback "nil"
        ?value t
       );hCBB
      buttonList = cons(nameVar buttonList)
      i++
     );while

    layerMenu = hiCreateAppForm(
      ?name          'myForm
      ?formTitle     "Test form"
      ?callback      nil
      ?fields        buttonList
      );hCAF

    hiDisplayForm(layerMenu)
    );

    Many thanks for the help guys!

     

    • 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