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

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

 

/* Example 2c. How to put a series of objects into an */

/* empty aggregate by performing a Modify alteration  */

/* on the aggregate.                                  */

 

/* Performing a Modify alteration on an aggregate     */

/* allows the programmer to change the contents of    */

/* the aggregate while staying at the level of the    */

/* aggregate itself. The Cursor does not have to move */

/* into the aggregate in order to add new objects to  */

/* the aggregate.  Instead, the programmer simply     */

/* uses a block aggregating Modify alteration to      */

/* collect the new objects into the aggregate (assume */

/* the file has no contents):                         */

 

#include <stdlib.h>

#include "gfcursor.h"

 

int main(void) {

    short i = 2;

    char ch = 'b';

    double db = 3.14159;

    int valid;

    CURSOR *c = new_CURSOR(NULL,

      "newfile",

      AM_SHARED,

      NULL,

      0);

    eCursorQueryValid(c, &valid);

    if (!valid)

      exit(1);

    eAltModify(c);

    eAltStartAggregating(c); /* Start Aggregating */

    eObjWriteShort(c, i);

    eObjWriteChar(c, ch);

    eObjWriteDouble(c, db);

    eAltCommit(c);           /* End Aggregating   */

    delete_CURSOR(c);

    return 0;

}

/* Ending file layout:    */

/*   {                 }  */

/*    [2]['b'][3.14159]   */

 

/* Note that the objects within the aggregate are    */

/* placed in the order written. This particular type */

/* of modification is very powerful and will be      */

/* revisited in a later example. If the aggregate    */

/* had contained objects to begin with, all the      */

/* existing objects would have been removed as the   */

/* new contents of the aggregate were specified.     */

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.