In particular, I’m using the Python API. I would like to be able to look for objects by name to make the scripts more reusable.
Solved
Is there a ZOS-API equivalent to the ZPL OBJC(A$)?
Best answer by David.Nguyen
Hi Amy,
I don’t think this functions readily exists, but its relatively easy to program. Here’s a Python example for you:
# Function similar to ZPL OBJC
def object_comment(NCE, comment, case_sensitive=False):
# Number of objects in the NCE
object_num = NCE.NumberOfObjects
# Is the search case-sensitive?
if not case_sensitive:
# If the search is NOT case-sensitive put
# input comment in all small letters
comment = comment.lower()
# Initialize list of return indexes
ret_idx = []
# Loop over the objects and check the comments
for obj_idx in range(1, object_num+1):
# Retrieve current object comment
obj_comment = NCE.GetObjectAt(obj_idx).Comment
# Is the search case-sensitive?
if not case_sensitive:
# If the search is NOT case-sensitive put
# current object comment in all small letters
obj_comment = obj_comment.lower()
# If the comment matches, store the object index
if comment == obj_comment:
ret_idx.append(obj_idx)
# If list is empty return -1
if not ret_idx:
ret_idx = -1
# Return list of inices
return ret_idx
# Test the function
object_comment(TheSystem.NCE, 'aa')
If I use this snippet in an interactive extension with this NCE:

I get the following output:
[2, 5]
Does that make sense?
Take care,
David
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.