Library manager menu items

Discussion in 'Cadence' started by Roger Light, Jan 13, 2009.

  1. Roger Light

    Roger Light Guest

    Hi,

    I've been trying to add menu items to the library manager
    programmatically with something like the following:

    menuLabel = "Menu Label"
    (lmgrCreateMenuItem menuName "simple" '(("label" menuLabel) ("callback" ("menuCallback"))))

    This gives an error:

    *Error* lmgrCreateMenuItem: label must have a string
    value - ("label" menuLabel)

    Is there any way round this, or do I have to write out the strings as
    static strings?

    Thanks,

    Roger
     
    Roger Light, Jan 13, 2009
    #1
  2. Roger Light

    Roger Light Guest

    Answering my own questions again, the correct way to do this is
    something like:

    attributes = (list (list "label" menuLabel) (list "callback" (list
    "menuCallback")))
    (lmgrCreateMenuItem menuName "simple" attributes)

    Cheers,

    Roger
     
    Roger Light, Jan 13, 2009
    #2
  3. Roger Light wrote, on 01/13/09 15:37:
    Hi Roger,

    That's right, you have to ensure that the variable menuLabel is being evaluated.
    In your first case it wasn't, so it was just seeing the symbol menuLabel. You
    could make the code a little more readable by judicious use of the backquote
    operator:


    menuLabel = "Menu Label"
    (lmgrCreateMenuItem menuName "simple"
    `(("label" ,menuLabel) ("callback" ("menuCallback"))))

    The backquote operator allows a list to be quoted, everywhere except where a
    variable is preceded with either , (as above) or ,@ (for list splicing).

    See my previous treatise on macros for more details on backquotes:

    http://tinyurl.com/7epjjk

    Regards,

    Andrew.
     
    Andrew Beckett, Jan 13, 2009
    #3
  4. Roger Light

    Roger Light Guest

    Ah, very handy and much more readable like you say (although less
    obvious to the untrained eye, alas).
    Well worth bookmarking! As another point of reference, the details on
    the backquote and comma notation for lists is in sklanguser in the
    section "Backquote, Comma and Comman-At.

    Cheers,

    Roger
     
    Roger Light, Jan 13, 2009
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.