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

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

 

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

/* empty aggregate using the PostLast position.       */

/* The PostLast position is defined to be after the   */

/* last object within the immediately enclosing       */

/* aggregate. If the aggregate is empty, PostLast is  */

/* defined to be after any potential position of      */

/* objects contained within the aggregate. PostLast   */

/* is shown graphically as:                           */

/*      {  }                                          */

/*        >                                           */

/* Normally, PostLast is only shown when one or more  */

/* Cursors are actually in the PostLast position.     */

/* When in the PostLast position, a cursor may only   */

/* insert objects before its current position.        */

/* Append, Replace, Remove and Modify alterations are */

/* not possible from the PostLast position. The       */

/* following API calls may be used to add a series of */

/* data objects from the PostLast position (assume an */

/* empty file):                                       */

 

#include <stdlib.h>

#include "gfcursor.hpp"

 

int main(void) {

    short i = 2;

    char ch = 'b';

    double db = 3.14159;

    int valid;

    CURSOR *c = new CURSOR("newfile");

    c>eCursorQueryValid(&valid);

    if (!valid)

      exit(1);

    c>eCursorMoveIn();

/* Since aggregate is empty, Cursor moves to the  */

/* Null position. Cursor must move to PreFirst or */

/* PostLast in order to make alterations.         */

    c>eCursorMovePostLast();

    c>eAltInsert();

    c>eObjWrite(i);

    c>eAltInsert();

    c>eObjWrite(ch);

    c>eAltInsert();

    c>eObjWrite(db);

    delete c;

    return 0;

}

/* Ending file layout:    */

/*  {                 }   */

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

 

/* Note that the each Insert alteration placed the   */

/* object in the location immediately before the     */

/* PostLast position (resulting in the objects being */

/* ordered in the exact same order as the order in   */

/* which they were written).                         */

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.