/* Gamelon(tm) File I/O Library Sample Code - C++ Language */ /* (C)1994 Menai Corporation(tm) - Released for public use */ /* Example 8. How to conduct a Wandering Transaction */ /* alteration. */ /* The Wandering Transaction is simply an aggregation */ /* of multiple individual alterations. As a result, in */ /* order to specify a Wandering Transaction, the */ /* program need only indicate the beginning and end of */ /* the Wandering Transaction as follows: */ /* Beginning file layout: */ /* { } */ /* [2]{ }[3.14159] */ /* [5700304] */ #include #include "gfcursor.hpp" int main(void) { char newchar = 'u'; short i = 17; int valid; CURSOR *c = new CURSOR("newfile"); c->eCursorQueryValid(&valid); if (!valid) exit(-1); c->eCursorMoveIn(); c->eCursorMoveLast(); c->eCursorMovePrior(); c->eCursorMoveIn(); c->eCursorMovePostLast(); c->eAltBeginWanderingTransaction(); c->eAltInsert(); c->eObjWrite(newchar); c->eCursorMoveOut(); c->eCursorMovePreFirst(); c->eAltAppend(); c->eObjWriteAggregate(); c->eCursorMoveNext(); c->eAltModify(); /* Note: Newly added aggregate not */ /* accessible yet. Object being modified */ /* is the data object containing '2'. */ c->eObjWrite(i); c->eAltCommitWanderingTransaction(); delete c; return 0; } /* Ending file layout: */ /* { } */ /* {}[17]{ }[3.14159] */ /* [5700304]['u'] */ /* Any and all individual simple or block alterations */ /* specified between the Begin Wandering Transaction */ /* and Commit Wandering Transaction calls will be */ /* submitted to the file as a single set of changes. */ /* They will only be written to file if all the */ /* specified changes can be written to file at the */ /* same time. */