/* Gamelon(tm) File I/O Library Sample Code  C Language   */

/* (C)1994 Menai Corporation(tm)  Released for public use */

 

/* Example 10b. How to use a Cursor to scan objects   */

/* within an aggregate (including nested aggregates). */

 

/* The sample code given in Example 10a will not      */

/* affect objects contained within nested aggregates  */

/* within the top level of the aggregate. The         */

/* following example sets the class number for the    */

/* top level aggregate and all the objects contained  */

/* within the top level aggregate, including any      */

/* objects nested within contained aggregates.        */

 

#include <stdlib.h>

#include <stdio.h>

#include "gfcursor.h"

 

void CheckObjects( CURSOR *);

void CheckObjects( CURSOR *c) {

    int answer;

    EC0 error;

    eCursorQueryOnObject(c, &answer);

    while (answer) {

      eAltModify(c);

      eObjSetClass(c, 4000000);

      eAltCommit(c);

/* Function returns an error if current object */

/* is not an aggregate. */

      error = eObjQueryAggregateEmpty(c, &answer);

      if (!error && !answer) {

        eCursorMoveIn(c);

        CheckObjects(c);

        eCursorMoveOut(c);

        error = eCursorMoveNext(c, OT_OBJ);

        if (!error) answer = 1;

      }

      else {

        error = eCursorMoveNext(c, OT_OBJ);

        if (error) answer = 0;

      }

    } /* end while */

}

int main(void) {

    int valid;

    CURSOR *c = new_CURSOR(NULL,

      "newfile",

      AM_SHARED,

      NULL,

      0);

    eCursorQueryValid(c, &valid);

    if (!valid)

      exit(1);

    CheckObjects(c);

    delete_CURSOR(c);

    return 0;

}

Download this sample source code

Return to Samples List

 Home | Product | Consulting | Programming | Reviews | Company | Site Map | Guest Book

 Menai Corporation, 1010 El Camino Real, Suite 300, Menlo Park, California 94025-4335
 800-GAMELON (800-426-3566) (US only), 650-853-6450 (voice), 650-853-6453 (fax)
 Questions about our products and services:
info@menai.com.
 Comments about this web site:
webmaster@menai.com.

Copyright © 1996-98 Menai Corporation. All Rights Reserved. Menai, Gamelon and gamelon(stylized) are worldwide trademarks of Menai Corporation, registered in the United States of America, and the .[g] logo is a worldwide trademark of Menai Corporation. All other trademarks are owned by their respective owners.