defstruct Questions

Discussion in 'Cadence' started by Jester_EE, Jan 4, 2008.

  1. Jester_EE

    Jester_EE Guest

    I have a few questions with the use of defstruct in a SKILL program I
    am currently working on.

    1. I am currently globally defining the defstruct, but when I use the
    make_<name> command in a procedure, it doe not know how to make the
    structure. I found that if I redefine the defstruct in the procedure
    it works, but I'd rather define it with the rest of the global data
    structures I am using and not throughout my code. Any thoughts on
    what I'm doing wrong?

    ex.
    defstruct(mystruct field1 field2 field3)

    cv = geGetWindowCellView()
    structList = myproc(cv)

    procedure( myproc(cv)
    let(x tlist
    ; defstruct(mystruct field1 field2 field3) ;This line needs to be
    uncommented to work properly
    tlist = nil
    foreach(x cv~>instanceMasters
    tlist = append1(tlist make_mystruct(
    ?field1 "Infoa"
    ?field2 "Infob"
    ?field3 "Infoc"
    )
    )
    )
    tlist
    )
    )

    2. When passing a list of defstructs to another procedure, it seems to
    be losing it's association as a defstruct and becoming an array. I
    know the data is stored as an array, but I no can longer reference the
    elements by the defined structure fields. Thoughts?

    ex.

    myproc2(structList)

    procedure( myproc2(listOfStructs)
    let( (y)
    foreach(y listOfStructs
    someOtherProc(y->field1)
    )
    )
    )

    Any thoughts would be appreciated.

    Thanks
    Matt
     
    Jester_EE, Jan 4, 2008
    #1
  2. Jester_EE

    Jester_EE Guest

    I fixed my 2nd problem on my own. In the true code (not the example
    above), I accidentally named my local 'listOfStructs' variable the
    same as the defstruct type. The error was ambiguous and threw me off
    track.

    Still could use some help on the 1st problem though. I'm sick of the
    CIW getting flooded with warnings of functions being redefined.

    Thanks again!
    Matt
     
    Jester_EE, Jan 4, 2008
    #2
  3. Jester_EE

    S. Badel Guest

    procedure( myproc(cv)
    A comment : your syntax is wrong regarding the let() statement.

    The first argument should be a *list* of the local variables, ie

    let( (x tlist)

    tlist = nil

    ...

    ) ; let

    Note that the first statement (tlist=nil) is useless, since the variables are already initialized to
    nil within the let(). Also, x doesn't need to be made local as this is done by the foreach
    statement. Let me suggest a rewrite of this procedure :

    procedure( myproc( cv )
    foreach(mapcar x cv~>instanceMasters
    make_mystruct(
    ?field1 "Infoa"
    ?field2 "Infob"
    ?field3 "Infoc"
    ) ; make_mystruct
    ) ; foreach
    ) ; procedure


    Other than this, I see no problem. The defstruct doesn't need to be inserted in the procedure.


    Cheers,

    Stéphane
     
    S. Badel, Jan 8, 2008
    #3
  4. Jester_EE

    Jester_EE Guest

    Stéphane,

    Thank you for your feedback, I really appreciate it. The first error
    (the let call) was a typo, but the mapcar implementation seemed to
    work well and removed the error I was getting without the defstruct
    being redefined each procedure call. Kinda strange that it worked
    differently, but I won't complain.

    However, the example I posted was a watered down version of what I am
    doing and currently I need to access the list as it's being built to
    look for repetitive entries. Is there a way to access the uncompleted
    list while still inside the mapcar function?

    Thanks again!
    Matt
     
    Jester_EE, Jan 8, 2008
    #4
  5. Jester_EE

    S. Badel Guest

    However, the example I posted was a watered down version of what I am
    I think not. But that's definitely not your problem, you can revert to your previous implementation,
    it shouldn't change anything. Maybe just a restart of icfb solved you problem...


    Stéphane
     
    S. Badel, Jan 9, 2008
    #5
  6. Jester_EE

    Jester_EE Guest

    Stéphane

    Many thanks!

    Matt
     
    Jester_EE, Jan 9, 2008
    #6
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.