How to check if lib, cell, or view exists?

Discussion in 'Cadence' started by Reotaro Hashemoto, Jun 25, 2009.

  1. Hi,

    I was using a SKILL code to let the use graphically browse for a cell.
    I tried to check if the lib, cell, or view exists, and if not print an
    error message and return nil.

    This is my trial:
    libName = CSForm->srcLib->value
    cellName = CSForm->srcCell->value
    viewName = CSForm->srcView->value

    ; Try to check if lib, cell, and view exists otherwise give error and
    return(nil)!!!
    prog(()
    when( null(ddGetObj(libName))
    printf("Unkown library %L" libName)
    return(nil)

    when( null(ddGetObj(libName cellName))
    printf("Unknown cell %L" cellName)
    return(nil)

    when( null(ddGetObj(libName cellName viewName))
    printf("Unknown view %L" viewName)
    return(nil)
    )
    )
    )
    ); prog

    I can't catch why it is not working..

    Any notice?
    Thanks,
    Ahmad
     
    Reotaro Hashemoto, Jun 25, 2009
    #1
    1. Advertising

  2. Reotaro Hashemoto wrote, on 06/25/09 08:52:
    > Hi,
    >
    > I was using a SKILL code to let the use graphically browse for a cell.
    > I tried to check if the lib, cell, or view exists, and if not print an
    > error message and return nil.
    >
    > This is my trial:
    > libName = CSForm->srcLib->value
    > cellName = CSForm->srcCell->value
    > viewName = CSForm->srcView->value
    >
    > ; Try to check if lib, cell, and view exists otherwise give error and
    > return(nil)!!!
    > prog(()
    > when( null(ddGetObj(libName))
    > printf("Unkown library %L" libName)
    > return(nil)
    >
    > when( null(ddGetObj(libName cellName))
    > printf("Unknown cell %L" cellName)
    > return(nil)
    >
    > when( null(ddGetObj(libName cellName viewName))
    > printf("Unknown view %L" viewName)
    > return(nil)
    > )
    > )
    > )
    > ); prog
    >
    > I can't catch why it is not working..
    >
    > Any notice?
    > Thanks,
    > Ahmad
    >


    Ahmad,

    Because it will never reach the second when if the library exists. The first
    condition is null(ddGetObj(libName)) - that will be true if the library does not
    exist, and so the whole of the code inside the when body only gets executed if
    the library does not exist. The same is true for the second when.

    A better approach is:

    cond(
    (!ddGetObj(libName)
    printf("Unknown library %s\n" libName)
    nil)
    (!ddGetObj(libName cellName)
    printf("Unknown cell %s\n" cellName)
    nil)
    (!ddGetObj(libName cellName viewName)
    printf("Unknown view %s\n" viewName)
    nil)
    ; it exists, so return t
    (t t)
    )

    cond() is essentially an efficient and compact if-elseif-elseif-else type form.

    Regards,

    Andrew.
     
    Andrew Beckett, Jun 25, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Erik Wanta

    NSRESULT: File exists

    Erik Wanta, Dec 17, 2003, in forum: Cadence
    Replies:
    2
    Views:
    128
    G Vandevalk
    Dec 17, 2003
  2. Suresh Jeevanandam

    Skill Qn: How to check if a cellview exists

    Suresh Jeevanandam, Nov 28, 2005, in forum: Cadence
    Replies:
    2
    Views:
    134
    Andrew Beckett
    Nov 28, 2005
  3. Juve
    Replies:
    2
    Views:
    130
    vtcad
    Dec 23, 2008
  4. Urs Klahr
    Replies:
    2
    Views:
    182
    Urs Klahr
    Sep 22, 2004
  5. Mark Propst
    Replies:
    5
    Views:
    180
    Tony Tanzillo
    Sep 19, 2003
Loading...

Share This Page