CAD Forums


Reply
Thread Tools Display Modes

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

 
Reotaro Hashemoto
Guest
Posts: n/a
 
      06-25-2009
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

 
Reply With Quote
 
 
 
 
Andrew Beckett
Guest
Posts: n/a
 
      06-25-2009
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell view name nour Cadence 10 11-18-2008 09:21 PM
incrementation of a cell view name nour Cadence 1 08-20-2008 08:16 AM
creating a new schematic cell view nour Cadence 1 06-13-2008 10:20 AM
Skill Qn: How to check if a cellview exists Suresh Jeevanandam Cadence 2 11-28-2005 11:11 AM
Bentley View: accessing cell libraries (*.cell, *.cdx) Urs Klahr Microstation 2 09-22-2004 06:18 AM


All times are GMT. The time now is 09:07 AM.