print values of a struct without knowing the slot names

Discussion in 'Cadence' started by RolfK, Aug 12, 2008.

  1. RolfK

    RolfK Guest

    Dear ALL,

    I need to understand how I can print out a struct.
    Assume ebb1 is an existing struct with values from which I do not know
    its slot names.

    Here is my (not working ) attempt.

    Any idea how to make it running ?

    foreach( (slot value) ebb1->?
    printf("%s\n" slot))
    /* The statement below can not work as slot is not treated as a
    variable.
    How to make it right ? */
    printf("%L\n" ebb1->slot);
    )
     
    RolfK, Aug 12, 2008
    #1
  2. RolfK

    S. Badel Guest

    What you're looking for is get(ebb1 slot).

    Note that the -> operator is equivalent to getq(), which means the second argument (slot) is not
    evaluated ; since the slot name - which you want to access - is in the value of the slot variable
    (symbol), you need to evaluate it by using get().


    Stéphane
     
    S. Badel, Aug 12, 2008
    #2
  3. RolfK

    Joel Guest

    Also,

    ebb1->??

    is useful for examining an unkown structure.
     
    Joel, Aug 13, 2008
    #3
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.