VgaGames4 - object man-pages

[.. upper level ..]

vg4->object->list()

Return a list of instance-IDs for an object-ID (or for all objects).

SYNTAX
int vg4->object->list(const char *objid, int subid, unsigned int **idlist)

FUNCTION PARAMETERS
objid Object-ID, or NULL = all object-instances
subid Sub-ID for object-ID, or 0 = don't check sub-ID
idlist For returning list of instance-IDs, must be freed with free(), returns NULL if no object-instances were found

RETURN VALUE
Returns the number of instance-IDs in the list

DESCRIPTION
Return a list of instance-IDs for an object-ID (or for all objects). If idlist is NULL, this function returns just the number of instance-IDs.

EXAMPLE
int numberof, ipos;
unsigned int *idlist;
struct VG_Object *objp;

/* get object-instances of object OTEST */
numberof = vg4->object->list("OTEST", 0, &idlist);
printf("%d instances of OTEST found:\n", numberof);

/* list instances and the object they belong to, which is of course OTEST */
for (ipos = 0; ipos < numberof; ipos++) {
  objp = vg4->object->instance_getobj(idlist[ipos]);
  printf(" - %u: object %s\n", idlist[ipos], objp->objid);
}

/* free list if not NULL */
if (idlist != NULL) { free(idlist); }

SEE ALSO
vg4->object->has_instances()