Your code does not appear to have any relationship to your request. Your posted code scans a drawing to find out how many block references you have with a given name.
This code is another way to do the same thing as your code body. I am not sure it is any better.
(IF (VL-CATCH-ALL-ERROR-P
(VL-CATCH-ALL-APPLY
'(LAMBDA (name)
(ALERT
(STRCAT "There are "
(ITOA (SSLENGTH (SSGET "x" (LIST (CONS 2 name)))))
"block references with the name "
name
".")))
(LIST (SETQ name (GETSTRING "\nBlock name: ")))))
(ALERT
(STRCAT "There are no block references to the block name "
name
".")))
To answer your OP, if you are storing block names, then the above (or something similar ) could be used to establish whether references exist to a block name. If you want to store the names of entities that are not block references, then use handles. Every object has a handle. Assuming that ename is an entity name.
(cdr(assoc 5 (entget ename))) returns its handle.
If you store a handle, then it is easy to determine the entity still exists.
(handent <handle>) will return nil if the entity doesn't exist. Otherwise it will return the entity's ename.
If you store handles, try storing them in a dictionary rather than as ldata.
Architect, Registered NC, VA, SC, & GA.