Run through the selection amount

Top  Previous  Next

/* Run through the selection amount */

/ * ================================*/

#include "moskito.h"/* is everything in it */

#include "assert.h"/* for assert () */

 

/*

 

The following routine shows the run through the selection amount. Besides, the object keys are questioned by all objects from the selection amount. The example contains two variations. The first variation is slower, however, has for it the advantage that no unnecessary storage space is used. The second variation is quicker for it, however, more storage space which is not maybe used books.

 

Call:

Echo LaufDurchSelektionsmenge () spends the sum of the objects.

 

*/

long int EXPORTENTRY LaufDurchSelektionsmenge (int argc, char* argv [], PROOT ptrRoot)

{

POBJECT ptrSLObj = ZERO;

int iAnzObj = 0;/* number of the objects */

 

for (ptrSLObj = DBfirstObjectOfSelectionList (ptrRoot);

ptrSLObj;

ptrSLObj = DBnextObjectOfSelectionList (ptrSLObj))

{

iAnzObj ++;

{/* 1st possibility */

int iKeyCnt = 0;/* only number investigate */

KEY *ptrKeys = ZERO;

 

if (ERROR_OK == DBreturnObjectKeys (ptrSLObj,

&iKeyCnt,

now ptrKeys))/* is any */

{

/* now in iKeyCnt stands the number of the object keys */

 

ptrKeys = (KEY *) Malloc (iKeyCnt * sizeof (KEY));

/* Now memories get */

assert (ptrKeys);

DBreturnObjectKeys (ptrSLObj, &iKeyCnt, ptrKeys);

 

//...

 

Free (ptrKeys);/* give a holiday Again! */

}

else

/* Mistake treatment... */;

} /* In the end of 1. Possibility */

 

{/* 2nd possibility */

int iKeyCnt = 100;/* or even greater */

KEY ptrKeys [100];/* the same size */

 

DBreturnObjectKeys (ptrSLObj, &iKeyCnt, ptrKeys);

if (iKeyCnt) {

//...

}

else

/* Mistake treatment... */;

} /* In the end of 2. Possibility */

} //for

return iAnzObj;

} //LaufDurchSelektionsmenge

/*---------------------------------------------------------------------------*/